You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-10-13] Agent - Not here page appears briefly when copiloting into agent's account #99507
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Reproduced on web. Clicking Copilot into account from an agent's profile briefly flashes a full-page blocking view before the copiloted account settles. The flashed screen is the copilot "Not so fast… As a copilot, you don't have access to this page. Sorry!" interstitial (a variant of FullPageNotFoundView / the "Not here" page) — it self-recovers with no lasting error.
Root cause (Medium-High confidence): the copilot switch changes the session in place and never resets navigation to a copilot-valid landing screen. So the settings route the switch was triggered from stays mounted, and once openApp() completes and account.delegatedAccess.delegate becomes truthy, that still-mounted route re-evaluates its delegate guard and renders the blocking view for a frame or two until the app settles.
Investigation details & evidence (SHA bb012ae)
The flashed screen and its condition — DelegateNoAccessWrapper.tsx:56-76 renders FullPageNotFoundView with titleKey="delegate.notAllowed" ("Not so fast…") + subtitleKey="delegate.noAccessMessage" ("As a copilot, you don't have access to this page. Sorry!") whenever isDelegate(account) is true, i.e. account.delegatedAccess.delegate is set. Those strings are en.ts:10604-10607.
No navigation reset on switch — useSwitchToDelegator.ts:79-86 just calls connect(...); there is no Navigation.resetToHome/redirect afterward.
The transition window — Delegate.connect (Delegate.ts:145-251): after the CONNECT_AS_DELEGATE request it swaps the auth token, disconnects Pusher, clearOnyxForDelegateTransition() (seeds IS_LOADING_APP=true), then openApp(). The IS_LOADING_APP=true seed exists precisely to tell consumers "we're mid-transition" — but the delegate guards here don't read it, so they fire anyway. This is the same transition-window race class as the fixes tracked in #98721, #97769, #97843 and the closed #97695, re-exposed on the new Agents screens.
Secondary flash path — EditAgentPage.tsx:52,87-88 guards with shouldShowNotFoundPage = isOnyxLoaded && !agent && !personalDetails and returns the generic NotFoundPage ("Not here"). When the Onyx clear wipes agent/personal-details data while useOnyx metadata is still loaded, this can also flash the generic "Not here" page (matching the issue title's wording). Same fix applies.
Proposal
What is the root cause of that problem?
Copiloting switches the account session in place without redirecting away from the current settings route, and the delegate "no access" / "not found" guards on that route don't account for the in-progress transition. When openApp() finishes and account.delegatedAccess.delegate flips to set (and cleared Onyx collections briefly read as empty), the still-mounted Agents/settings route re-renders its guard and shows a full-page blocking view ("Not so fast… you don't have access" — or the generic "Not here") for a frame or two before the app settles and redirects.
What changes do you think we should make in order to solve the problem?
Two viable directions:
Suppress blocking views during the delegate transition (matches the existing mechanism): gate the guards on the already-seeded IS_LOADING_APP so they don't fire while the switch is in flight — e.g. in DelegateNoAccessWrapper.tsx skip FullPageNotFoundView while IS_LOADING_APP is true, and likewise add an !isLoadingApp term to EditAgentPage.tsx:52.
Reset navigation as part of the switch: after connect() succeeds, redirect to a copilot-valid landing screen (Home) so no stale Agents/settings route is left mounted to re-evaluate its guard.
Option 1 is the lower-risk, more targeted fix and reuses the IS_LOADING_APP signal the transition already sets for exactly this purpose.
What alternative solutions did you explore? (Optional)
Preserving PERSONAL_DETAILS_LIST / the agent-prompt collection across the Onyx clear would suppress the generic "Not here" path but would not stop the copilot "no access" flash (that one is driven by the delegate flag, not empty data), so it's incomplete on its own.
Tester verification (web)
Result: pass — the flash reproduces and self-recovers, as described.
Step
Status
Observation
Navigate to Account > Agents
pass
Agents (Beta) list opened
Create a new agent
pass
Created agent "TipMaster" (agent_…@expensify.ai)
Open agent profile
pass
"Edit agent" panel with Chat / Copilot into account / Delete
Click "Copilot into account"
pass
Account context switched to the agent
Brief "not accessible" flash before settling
pass
~250ms in, a semi-transparent "Not so fast… As a copilot, you don't have access to this page. Sorry!" overlay showed over the loading Profile pane
Flash self-recovers without user action
pass
Overlay disappeared; agent's Profile rendered normally, no error
Evidence (3)
Mid-transition: 'Not so fast... As a copilot, you don't have access to this page. Sorry!' overlay flashing over the loading Profile pane after clicking Copilot into account
Cropped view of the flashed copilot restricted-access message
Final self-recovered state: copiloted into the agent account, Profile rendered normally
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/99507) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
The Melvin RCA is incorrect. The not found page comes from withAgentAccessDenied after ConnectAsDelegate API is done because the response updates accountID in session to agent's accountID. We should add a flag to know when we're switching to Copilot and prevent the not found page here when this flag is true.
The brief page is rendered by withAgentAccessDenied, not by EditAgentPage losing its agent data.
After ConnectAsDelegate succeeds, the session switches to the agent account while the old Agents route is still mounted. useIsAgentAccount() then returns true, so the wrapper starts dismissing the RHP and redirecting the agent to Profile:
That condition describes the destination, not the redirect lifecycle. As soon as Profile becomes the active route, shouldRedirect flips to false, even though the old guarded screen can remain mounted until the RHP/navigation transition finishes. The next render therefore reaches this branch and briefly paints the reported page:
This also explains why checking only IS_LOADING_APP is not reliable. useIsAgentAccount() deliberately starts trusting a loaded personal-details entry even if OpenApp is still running, so the agent identity can become known before the navigation transition has unmounted the old route:
PR #97869 added the asynchronous modal-dismiss/Profile redirect for this same transition, but the render condition still forgets that a redirect was already started.
What changes do you think we should make in order to solve the problem?
Track the redirect started by each guarded wrapper instance and keep that instance hidden until it unmounts.
Add a useRef(false) such as isAgentRedirectInProgressRef. In redirectAgentAway, set it to true before waiting for navigation readiness, but only when shouldRedirect is true. Then include that ref in the null-render branch:
The ref must not be cleared merely because Profile becomes active. The guarded component unmounting is the completion signal for this instance. It should only reset if the same mounted wrapper returns to a non-agent session.
This is narrower than a global “switching account” flag and preserves the existing deliberate-access behavior. If an agent later opens a guarded RHP while Profile is already active, that new wrapper has not initiated a redirect, so it can still show the access-denied page. Only the stale wrapper that actually launched the redirect remains hidden.
Extend withAgentAccessDenied.test.tsx with the real sequence: render as the owner, change identity to an agent while the guarded route is active, let the wrapper initiate the redirect, then make Profile active before unmounting the wrapper. Assert that neither the protected content nor delegate.notAllowed is rendered during that final transition render. Keep the existing test proving a fresh guarded wrapper can show access denied when Profile was already active.
What alternative solutions did you explore? (Optional)
Gating EditAgentPage.shouldShowNotFoundPage on IS_LOADING_APP does not stop the page captured in the video because it comes from withAgentAccessDenied.
Returning null for every agent permanently removes the intentional access-denied state for a later direct visit.
A global Onyx transition flag needs careful clearing across API failure, OpenApp, and modal animation. The wrapper-local redirect latch follows the exact UI lifecycle that causes the flash.
🚨 Edited by proposal-police: This proposal was edited at 2026-08-30 06:42:14 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When the owner opens an agent from Account > Agents and taps Copilot into account, the copilot "Not so fast… As a copilot, you don't have access to this page. Sorry!" blocking page flashes for a frame or two before the copiloted account's Profile settles.
What is the root cause of that problem?
Every Agents screen — the Agents list in the central pane and the agent-edit RHP the Copilot into account button lives in (SCREENS.SETTINGS.AGENTS.EDIT) — is wrapped in withAgentAccessDenied. Its render has three outcomes, keyed on useIsAgentAccount() and on whether Profile (the redirect target) is already the active route:
So the blocking view paints only when isAgent === trueandisAlreadyOnRedirectTarget === true (then shouldRedirect is false and the render falls past the null guard into the FullPageNotFoundView branch).
Copiloting runs connect(), which swaps the auth token, then clearOnyxForDelegateTransition() + openApp() for the agent:
Once openApp() returns the agent's personal details (isCustomAgent: true), useIsAgentAccount() flips from undefined to true while the agent-edit RHP is still mounted and focused, so the guard fires its redirect. Because the RHP is the topmost modal, it dismisses the modal and defers the Profile forceReplace to after the transition:
On web the deferred forceReplace of the central pane lands while the dismissed RHP is still mounted for its exit animation (the attached video shows the central pane already on Profile while the RHP is still fading). From that moment Navigation.isActiveRoute(SETTINGS_PROFILE) is true, so on the RHP's next render — it keeps re-rendering as openApp data streams into the hooks the guard subscribes to — isAlreadyOnRedirectTarget is true, shouldRedirect is false, and the render drops into the isAgent === true branch and paints "Not so fast…" inside the RHP that is on its way out. That is the flash in the video.
The key point: the isAlreadyOnRedirectTarget fallback was written for a guarded screen that is actually the one being shown, but here it is reached by a screen that has already been dismissed and is only still mounted for its exit animation. And the guard already draws this exact distinction elsewhere — the focus-independent redirect effect added by the blank-background fix exists precisely because an unfocused guarded agent screen must be corrected, not shown:
The redirect path became focus-aware; the render branch did not. That asymmetry is the bug. It is the same transition-window race class as #98721 / #97769 / #97843, re-exposed on the new Agents screens.
What changes do you think we should make in order to solve the problem?
In withAgentAccessDenied, paint the blocking view only when the guarded screen is actually focused (i.e. the visible one). The guard already reads useIsFocused(); when isAgent === true but the screen is not focused, return null — the same "nothing yet" output the shouldRedirect path already uses — instead of FullPageNotFoundView:
if(isAgent===undefined||shouldRedirect){returnnull;}if(isAgent===true){// Only the focused (visible) screen may paint the blocking view. An unfocused agent screen is either// dismissing (the agent-edit RHP mid exit-animation while the central pane has already forceReplaced to// Profile) or a background pane behind the redirect target - the focus-independent effect above already// redirects it, so there is nothing to show and FullPageNotFoundView would only paint the flash.if(!isFocused){returnnull;}return(<FullPageNotFoundViewshouldShowtitleKey="delegate.notAllowed"subtitleKey="delegate.noAccessMessage"shouldShowLink={false}/>);}return<Component{...props}/>;
This is timing-independent and adds no global state: a guarded screen that has lost focus after the session flipped to an agent (an RHP animating closed after dismissModal, or a pane behind Profile) has nothing to show, and the focus-independent effect above is already redirecting it. A focused guarded screen keeps the existing behaviour, so the deliberate "already on the redirect target" case still renders the blocking view. The redirect logic is untouched.
What specific scenario / automated test would you use to validate this change works?
Add a case to tests/unit/withAgentAccessDenied.test.tsx mirroring the existing "already on the redirect target" test but with the screen unfocused: mockIsScreenFocused = false, Navigation.isActiveRoute → true, signed in as agent, and assert that neither protected-content nor "Not so fast..." is rendered (the guard returns null). The existing focused case must still assert the blocking view renders:
That pair proves the branch is suppressed only for the unfocused/dismissing screen and preserved for a genuinely displayed one. The other existing tests (redirect, RHP-dismiss, unfocused-pane redirect, non-agent, identity-loading) pass unchanged — verified locally, full suite green.
What alternative solutions did you explore? (Optional)
Add a transient "switching to copilot" Onyx flag (e.g. IS_CONNECTING_AS_DELEGATE) set in connect() and hide the blocking view while it is set. This adds global state that must be set and cleared at exactly the right moments, and the flash lives during the RHP exit animation — after openApp() has already resolved and the redirect has been dispatched — so the flag would have to stay set until the RHP finishes unmounting, which connect() cannot cleanly know. Checking focus at render time is deterministic and needs no such coordination.
Gate the guard on IS_LOADING_APP. It is already back to false by the time the flash occurs — the flash window is afteropenApp() resolves, and that resolution is exactly what flips isAgent to true — so it does not cover the window.
Reset navigation to Profile/Home as part of the switch itself (in useSwitchToDelegator, after connect() succeeds). This also closes the flash but is broader — it touches the shared switch flow for every guarded screen — and still races the async dismiss/replace, so the guard-level fix is the more targeted one.
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: NA
Link to the comment on the Issue:
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Precondition:
NA
Test:
Navigate to Account > Agents
Create a new agent
Click the agent's row
Click copilot into account
Verify that the RHP is closed without displaying not found page briefly
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
applause-bot commentedon Aug 26, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/7620d15762b23f8b70d181ee2de0510a32f7eb78a7b1929080ff63a338ce1491
MelvinBot commentedon Aug 26, 2026
Issue Analysis
Reproduced on web. Clicking Copilot into account from an agent's profile briefly flashes a full-page blocking view before the copiloted account settles. The flashed screen is the copilot "Not so fast… As a copilot, you don't have access to this page. Sorry!" interstitial (a variant of
FullPageNotFoundView/ the "Not here" page) — it self-recovers with no lasting error.Root cause (Medium-High confidence): the copilot switch changes the session in place and never resets navigation to a copilot-valid landing screen. So the settings route the switch was triggered from stays mounted, and once
openApp()completes andaccount.delegatedAccess.delegatebecomes truthy, that still-mounted route re-evaluates its delegate guard and renders the blocking view for a frame or two until the app settles.Investigation details & evidence (SHA
bb012ae)The flashed screen and its condition —
DelegateNoAccessWrapper.tsx:56-76rendersFullPageNotFoundViewwithtitleKey="delegate.notAllowed"("Not so fast…") +subtitleKey="delegate.noAccessMessage"("As a copilot, you don't have access to this page. Sorry!") wheneverisDelegate(account)is true, i.e.account.delegatedAccess.delegateis set. Those strings areen.ts:10604-10607.No navigation reset on switch —
useSwitchToDelegator.ts:79-86just callsconnect(...); there is noNavigation.resetToHome/redirect afterward.The transition window —
Delegate.connect(Delegate.ts:145-251): after theCONNECT_AS_DELEGATErequest it swaps the auth token, disconnects Pusher,clearOnyxForDelegateTransition()(seedsIS_LOADING_APP=true), thenopenApp(). TheIS_LOADING_APP=trueseed exists precisely to tell consumers "we're mid-transition" — but the delegate guards here don't read it, so they fire anyway. This is the same transition-window race class as the fixes tracked in #98721, #97769, #97843 and the closed #97695, re-exposed on the new Agents screens.Secondary flash path —
EditAgentPage.tsx:52,87-88guards withshouldShowNotFoundPage = isOnyxLoaded && !agent && !personalDetailsand returns the genericNotFoundPage("Not here"). When the Onyx clear wipes agent/personal-details data whileuseOnyxmetadata is stillloaded, this can also flash the generic "Not here" page (matching the issue title's wording). Same fix applies.Proposal
What is the root cause of that problem?
Copiloting switches the account session in place without redirecting away from the current settings route, and the delegate "no access" / "not found" guards on that route don't account for the in-progress transition. When
openApp()finishes andaccount.delegatedAccess.delegateflips to set (and cleared Onyx collections briefly read as empty), the still-mounted Agents/settings route re-renders its guard and shows a full-page blocking view ("Not so fast… you don't have access" — or the generic "Not here") for a frame or two before the app settles and redirects.What changes do you think we should make in order to solve the problem?
Two viable directions:
IS_LOADING_APPso they don't fire while the switch is in flight — e.g. inDelegateNoAccessWrapper.tsxskipFullPageNotFoundViewwhileIS_LOADING_APPis true, and likewise add an!isLoadingAppterm toEditAgentPage.tsx:52.connect()succeeds, redirect to a copilot-valid landing screen (Home) so no stale Agents/settings route is left mounted to re-evaluate its guard.Option 1 is the lower-risk, more targeted fix and reuses the
IS_LOADING_APPsignal the transition already sets for exactly this purpose.What alternative solutions did you explore? (Optional)
Preserving
PERSONAL_DETAILS_LIST/ the agent-prompt collection across the Onyx clear would suppress the generic "Not here" path but would not stop the copilot "no access" flash (that one is driven by the delegate flag, not empty data), so it's incomplete on its own.Tester verification (web)
Result: pass — the flash reproduces and self-recovers, as described.
Evidence (3)
Mid-transition: 'Not so fast... As a copilot, you don't have access to this page. Sorry!' overlay flashing over the loading Profile pane after clicking Copilot into account
Cropped view of the flashed copilot restricted-access message
Final self-recovered state: copiloted into the agent account, Profile rendered normally
Possibly related issues
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/99507)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
j3ffffff commentedon Aug 26, 2026
melvin-bot commentedon Aug 26, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @thelullabyy (
External)melvin-bot commentedon Aug 26, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
nkdengineer commentedon Aug 26, 2026
The Melvin RCA is incorrect. The not found page comes from
withAgentAccessDeniedafterConnectAsDelegateAPI is done because the response updatesaccountIDinsessionto agent'saccountID. We should add a flag to know when we're switching to Copilot and prevent the not found page here when this flag istrue.App/src/libs/Navigation/AppNavigator/withAgentAccessDenied.tsx
Lines 79 to 90 in 5778821
thelullabyy commentedon Aug 29, 2026
🆘 C+ Help Wanted
annaweber830 commentedon Aug 29, 2026
Proposal
What is the root cause of that problem?
The brief page is rendered by
withAgentAccessDenied, not byEditAgentPagelosing its agent data.After
ConnectAsDelegatesucceeds, the session switches to the agent account while the old Agents route is still mounted.useIsAgentAccount()then returnstrue, so the wrapper starts dismissing the RHP and redirecting the agent to Profile:App/src/libs/Navigation/AppNavigator/withAgentAccessDenied.tsx
Lines 18 to 74 in e49e547
The wrapper hides itself only while this expression is true:
That condition describes the destination, not the redirect lifecycle. As soon as Profile becomes the active route,
shouldRedirectflips tofalse, even though the old guarded screen can remain mounted until the RHP/navigation transition finishes. The next render therefore reaches this branch and briefly paints the reported page:App/src/libs/Navigation/AppNavigator/withAgentAccessDenied.tsx
Lines 76 to 88 in e49e547
This also explains why checking only
IS_LOADING_APPis not reliable.useIsAgentAccount()deliberately starts trusting a loaded personal-details entry even if OpenApp is still running, so the agent identity can become known before the navigation transition has unmounted the old route:App/src/hooks/useIsAgentAccount.ts
Lines 26 to 41 in e49e547
PR #97869 added the asynchronous modal-dismiss/Profile redirect for this same transition, but the render condition still forgets that a redirect was already started.
What changes do you think we should make in order to solve the problem?
Track the redirect started by each guarded wrapper instance and keep that instance hidden until it unmounts.
Add a
useRef(false)such asisAgentRedirectInProgressRef. InredirectAgentAway, set it totruebefore waiting for navigation readiness, but only whenshouldRedirectis true. Then include that ref in the null-render branch:The ref must not be cleared merely because Profile becomes active. The guarded component unmounting is the completion signal for this instance. It should only reset if the same mounted wrapper returns to a non-agent session.
This is narrower than a global “switching account” flag and preserves the existing deliberate-access behavior. If an agent later opens a guarded RHP while Profile is already active, that new wrapper has not initiated a redirect, so it can still show the access-denied page. Only the stale wrapper that actually launched the redirect remains hidden.
Extend
withAgentAccessDenied.test.tsxwith the real sequence: render as the owner, change identity to an agent while the guarded route is active, let the wrapper initiate the redirect, then make Profile active before unmounting the wrapper. Assert that neither the protected content nordelegate.notAllowedis rendered during that final transition render. Keep the existing test proving a fresh guarded wrapper can show access denied when Profile was already active.What alternative solutions did you explore? (Optional)
EditAgentPage.shouldShowNotFoundPageonIS_LOADING_APPdoes not stop the page captured in the video because it comes fromwithAgentAccessDenied.nullfor every agent permanently removes the intentional access-denied state for a later direct visit.David-2002065 commentedon Aug 29, 2026
🚨 Edited by proposal-police: This proposal was edited at 2026-08-30 06:42:14 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When the owner opens an agent from Account > Agents and taps Copilot into account, the copilot "Not so fast… As a copilot, you don't have access to this page. Sorry!" blocking page flashes for a frame or two before the copiloted account's Profile settles.
What is the root cause of that problem?
Every Agents screen — the Agents list in the central pane and the agent-edit RHP the Copilot into account button lives in (
SCREENS.SETTINGS.AGENTS.EDIT) — is wrapped inwithAgentAccessDenied. Its render has three outcomes, keyed onuseIsAgentAccount()and on whether Profile (the redirect target) is already the active route:App/src/libs/Navigation/AppNavigator/withAgentAccessDenied.tsx
Lines 20 to 21 in 12a92bd
App/src/libs/Navigation/AppNavigator/withAgentAccessDenied.tsx
Lines 76 to 88 in 12a92bd
So the blocking view paints only when
isAgent === trueandisAlreadyOnRedirectTarget === true(thenshouldRedirectisfalseand the render falls past thenullguard into theFullPageNotFoundViewbranch).Copiloting runs
connect(), which swaps the auth token, thenclearOnyxForDelegateTransition()+openApp()for the agent:App/src/libs/actions/Delegate.ts
Lines 232 to 235 in 12a92bd
Once
openApp()returns the agent's personal details (isCustomAgent: true),useIsAgentAccount()flips fromundefinedtotruewhile the agent-edit RHP is still mounted and focused, so the guard fires its redirect. Because the RHP is the topmost modal, it dismisses the modal and defers the ProfileforceReplaceto after the transition:App/src/hooks/useIsAgentAccount.ts
Lines 38 to 41 in 12a92bd
App/src/libs/Navigation/AppNavigator/withAgentAccessDenied.tsx
Lines 48 to 49 in 12a92bd
On web the deferred
forceReplaceof the central pane lands while the dismissed RHP is still mounted for its exit animation (the attached video shows the central pane already on Profile while the RHP is still fading). From that momentNavigation.isActiveRoute(SETTINGS_PROFILE)istrue, so on the RHP's next render — it keeps re-rendering asopenAppdata streams into the hooks the guard subscribes to —isAlreadyOnRedirectTargetistrue,shouldRedirectisfalse, and the render drops into theisAgent === truebranch and paints "Not so fast…" inside the RHP that is on its way out. That is the flash in the video.The key point: the
isAlreadyOnRedirectTargetfallback was written for a guarded screen that is actually the one being shown, but here it is reached by a screen that has already been dismissed and is only still mounted for its exit animation. And the guard already draws this exact distinction elsewhere — the focus-independent redirect effect added by the blank-background fix exists precisely because an unfocused guarded agent screen must be corrected, not shown:App/src/libs/Navigation/AppNavigator/withAgentAccessDenied.tsx
Lines 69 to 74 in 12a92bd
The redirect path became focus-aware; the render branch did not. That asymmetry is the bug. It is the same transition-window race class as #98721 / #97769 / #97843, re-exposed on the new Agents screens.
What changes do you think we should make in order to solve the problem?
In
withAgentAccessDenied, paint the blocking view only when the guarded screen is actually focused (i.e. the visible one). The guard already readsuseIsFocused(); whenisAgent === truebut the screen is not focused, returnnull— the same "nothing yet" output theshouldRedirectpath already uses — instead ofFullPageNotFoundView:This is timing-independent and adds no global state: a guarded screen that has lost focus after the session flipped to an agent (an RHP animating closed after
dismissModal, or a pane behind Profile) has nothing to show, and the focus-independent effect above is already redirecting it. A focused guarded screen keeps the existing behaviour, so the deliberate "already on the redirect target" case still renders the blocking view. The redirect logic is untouched.Compare branch (implemented, local test suite green): https://github.com/Expensify/App/compare/main...dilshodmackbook-sketch:App:dilshod/99507-copilot-not-found-flash?expand=1
What specific scenario / automated test would you use to validate this change works?
Add a case to
tests/unit/withAgentAccessDenied.test.tsxmirroring the existing "already on the redirect target" test but with the screen unfocused:mockIsScreenFocused = false,Navigation.isActiveRoute → true, signed in as agent, and assert that neitherprotected-contentnor "Not so fast..." is rendered (the guard returnsnull). The existing focused case must still assert the blocking view renders:App/tests/unit/withAgentAccessDenied.test.tsx
Lines 172 to 185 in 12a92bd
That pair proves the branch is suppressed only for the unfocused/dismissing screen and preserved for a genuinely displayed one. The other existing tests (redirect, RHP-dismiss, unfocused-pane redirect, non-agent, identity-loading) pass unchanged — verified locally, full suite green.
What alternative solutions did you explore? (Optional)
IS_CONNECTING_AS_DELEGATE) set inconnect()and hide the blocking view while it is set. This adds global state that must be set and cleared at exactly the right moments, and the flash lives during the RHP exit animation — afteropenApp()has already resolved and the redirect has been dispatched — so the flag would have to stay set until the RHP finishes unmounting, whichconnect()cannot cleanly know. Checking focus at render time is deterministic and needs no such coordination.IS_LOADING_APP. It is already back tofalseby the time the flash occurs — the flash window is afteropenApp()resolves, and that resolution is exactly what flipsisAgenttotrue— so it does not cover the window.useSwitchToDelegator, afterconnect()succeeds). This also closes the flash but is broader — it touches the shared switch flow for every guarded screen — and still races the async dismiss/replace, so the guard-level fix is the more targeted one.66 remaining items
melvin-bot commentedon Oct 12, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Oct 12, 2026
Payment Summary
Resolving PRs:
fix: Not here page appears briefly when copiloting into agent's account #100803
Reviewer: @nkdengineer owed $175 via NewDot
Reviewer: @thelullabyy owed $175 via NewDot
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Oct 15, 2026
Payment Summary
Contributor: @nkdengineer due $250 via NewDot
Contributor+: @thelullabyy due $250 via NewDot
@thelullabyy plz complete the Contributor+ checklist and tag me in a post once you have. Thx
thelullabyy commentedon Oct 18, 2026
Contributor+ Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: NA
Link to the comment on the Issue:
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
thelullabyy commentedon Oct 18, 2026
@mallenexpensify I posted the BZ checklist. Thanks
laurenreidexpensify commentedon Oct 27, 2026
$250 Approved @thelullabyy New Expensify