[Due for payment 2026-11-14] [$175] fix: Stop the Inbox tab from reopening the previous account's report after a copilot switch
Problem
When a copilot switches accounts, the app clears Onyx but keeps the navigation state of every tab except Search. The Inbox tab still holds the report the previous account had open, so tapping Inbox after the switch reopens it. OpenReport returns 403 for the new account and the user sees "Hmm... it's not here".
Solution
Every copilot switch, in either direction, now clears all preserved navigator states and the last visited Workspaces and Settings tab paths. It then resets the root to the Settings tab (or Home when copiloting from an agent's own pages). ONBOARDING_MODAL_NAVIGATOR is now registered in every session, so browser back works after the reset, and OnboardingGuard redirects copilot and supportal sessions away from onboarding routes.
PR
https://github.com/Expensify/App/pull/105911
Issue Owner
Current Issue Owner: @mallenexpensifyUpwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022118123086873725163
- Upwork Job ID: 2118123086873725163
- Last Price Increase: 2026-11-04
Triggered auto assignment to Contributor-plus team member for initial proposal review - @jayeshmangwani (External)
Job added to Upwork: https://www.upwork.com/jobs/~022118123086873725163
🤖 Web test steps verification results: ⚠️ partial
Blocked on dev NewDot web: the supplied session rendered a blank page. No account was created, invited, or switched.
| Step | Status |
|---|---|
Account switcher offers an existing copilot/delegator accountUnable to verify: snapshots returned no application elements, and waiting for Account timed out.![]() |
❌ |
Returning and tapping Inbox does not reopen the previous account's reportNot exercised because the application UI was unavailable. The issue was neither reproduced nor ruled out. |
❌ |
Proposal
What is the root cause of that problem?
Account switching clears Onyx but leaves Inbox navigation pointing to the previous account’s report. Reopening Inbox can therefore request an inaccessible report. Confidence: medium; code supports this mechanism, but runtime reproduction was blocked.
Code evidence
The baseline Delegate.ts:253–292 clears only Search navigation. usePreserveNavigatorState.ts:7–38 stores navigation outside Onyx. On wide layouts, SplitRouter.ts:165–178 preserves the central report. The reported 403 was not independently verified.
What changes do you think we should make in order to solve the problem?
Review the existing Stop the Inbox tab from reopening the previous account’s report PR rather than create another fix. It clears navigation caches and resets the mounted navigation tree in both directions.
Fix scope and verification
The reset in Delegate.ts:75–89 calls cleanup in Navigation.ts:775–779, then resets the root. The return path invokes the same reset.
Verify wide-layout switches both ways, browser Back/Forward, agent entry, and onboarding redirects. Browser history can still reach inaccessible reports; the PR explicitly excludes that limitation. Web verification was blocked by a blank application page.
What alternative solutions did you explore? (Optional)
Clearing caches alone leaves mounted routes intact. Delayed deep links remain a separate possible cause, not ruled out here.
Related issue: Copilot—Not here after switching accounts and opening Inbox describes the same flow.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/pull/105911) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
view run · no recording available
Proposal
Please re-state the problem that we are trying to solve in this issue.
Al cambiar de cuenta mediante copilot, Inbox conserva una ruta del usuario anterior. Según el caso aportado, abrirla provoca un 403; no hay reproducción independiente.
What is the root cause of that problem?
⚠️ Why MelvinBot's proposal is insufficient / introduces regressions:
- No aporta reproducción ni tests ejecutados. Esto limita su validación; no demuestra que su solución sea incorrecta.
El material sitúa el borrado incompleto en src/libs/actions/Delegate.ts:253–292 y la persistencia externa a Onyx en usePreserveNavigatorState.ts:7–38. No pude verificar esos archivos ni identificar la función exacta: GitHub no fue accesible y el workspace no contiene el repositorio.
What changes do you think we should make in order to solve the problem?
Dictamen: propuesta todavía no apta para aceptación. El PR #105911, según el contenido aportado, ya cubre limpieza y reset en ambas direcciones. Proponer lo mismo presenta un riesgo directo de duplicidad.
Compare branch: https://github.com/Expensify/App/compare/main...camesenin:App:fix-issue-106042?expand=1
Ese enlace no acredita que exista una rama o un diff. Sin código verificable, presentar un parche de 3–10 líneas sería inventarlo. Registrar onboarding globalmente también exige validar guardas y navegación atrás.
What alternative solutions did you explore? (Optional)
Limpiar solamente cachés podría dejar rutas montadas; falta demostrarlo mediante un test. No hay evidencia para atribuir regresiones a MelvinBot. El 403 descrito tampoco acredita acceso entre cuentas ni fuga de datos.
What automated tests can you add to prevent this from re-occurring?
Exigir un test que falle antes del parche y pase después: conservar el reporte A, cambiar A→B y B→A, abrir Inbox y verificar que no restaura ni solicita el reporte anterior. Añadir cobertura de destinos Settings/Home y guardas de onboarding; los mocks de limpieza solos no prueban el comportamiento.
Contributor details
Your Expensify account email: [email protected]
Upwork Profile Link: https://www.upwork.com/freelancers/~01b60d704ba377be83
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Please re-state the problem that we are trying to solve in this issue
When a copilot switches accounts (in either direction), the Inbox tab still holds the report the previous account had open. Tapping Inbox after the switch reopens that report; OpenReport returns 403 for the new account and the user sees "Hmm... it's not here".
Current state of the fix on main
PR #105911 (linked in the issue body) is merged to main and addresses the core case. It introduces:
Navigation.clearSessionNavigationState()(src/libs/Navigation/Navigation.ts:775-779) which callsclearPreservedNavigatorStates()(the full wipe of the module-levelpreservedNavigatorStatesmap) andclearLastVisitedTabPaths().Delegate.resetNavigationForDelegateTransition()(src/libs/actions/Delegate.ts:75-88), which callsNavigation.clearSessionNavigationState()thennavigationRef.resetRoot({...getAdaptedStateFromPath(route), stale: true}).- It is invoked in
connect()(Delegate.ts:298) andrestoreDelegateSession()(Delegate.ts:1035), so both switch directions reset the navigator tree.
Before that PR, connect/disconnect only called clearPreservedSearchNavigatorStates() — which (per usePreserveNavigatorState.ts:32-38) deletes only keys starting with SEARCH_FULLSCREEN_NAVIGATOR, leaving the Inbox/Reports split navigator's preserved state intact. SplitRouter.getInitialState (src/libs/Navigation/AppNavigator/createSplitNavigator/SplitRouter.ts:189-190) then rehydrates that stale state on remount, reopening the inaccessible report. PR #105911 fixes exactly that.
Remaining gap (not covered by the merged PR)
PR #105911's description states an explicit Known limitation: "browser back after a switch can still reach the other account's pages, such as its reports, and those show 'Hmm... it's not here'. main behaves the same way."
So the residual bug is: after a copilot switch, pressing browser Back/Forward can land on a history entry for the previous account's report. Because the browser URL still references r/:reportID of the other account, linkTo() (src/libs/Navigation/helpers/linkTo/index.ts:178-…) dispatches a NAVIGATE/PUSH to that report, OpenReport runs with the new account's auth token, the server returns 403, and the user lands on ReportNotFoundGuard ("Hmm... it's not here"). The root navigation reset (stale: true) replaces the in-memory navigator state but does not scrub the cross-account report entries that the browser itself holds in window.history.
Proposed fix for the remaining gap
Guard the history-pop navigation so a cross-account report entry can't be replayed after a switch. Concretely:
- When a delegate transition completes (in
resetNavigationForDelegateTransition,Delegate.ts:76-88), afternavigationRef.resetRoot(...), callwindow.history.replaceStateto replace any cross-account report path in the current history entry with the reset target (e.g.ROUTES.SETTINGS/ROUTES.HOME), so Back doesn't handlinkToa staler/:reportID. (On native this is a no-op.) - In the
linkTopath that services history pops, before dispatching to aREPORTroute, check whether the targetreportIDbelongs to the current account (the existingisReportNotFound/ 403 path insrc/libs/actions/Report/index.ts:3525+already detects this after the request). Add an early guard so an inaccessible report routes to the last-valid screen instead of leaving the user on "Hmm... it's not here" with an unhandled Back stack.
This closes the limitation the merged PR explicitly left open, without touching the (correct) navigator-state reset.
What specific scenarios should be covered by automated tests?
- Switch A→B, press browser Back → landing screen is a B page, not A's report "Hmm… it's not here" (regression test for the known limitation).
- Switch A→B→A, press Back repeatedly → never reaches the other account's report.
- The already-merged PR's tests (switch and remount Inbox, wide/narrow, agent entry) must stay green — this proposal does not change that path.
PR
PR will be linked here once created.
Proposal
Please re-state the problem that we are trying to solve in this issue.
After switching accounts via Copilot (connect / disconnect), tapping the Inbox tab reopens the previous account's last viewed report URL (/r/<previousReportID>), which belongs to the previous account and fails with "Hmm... it's not here".
What is the root cause of that problem?
When switching accounts via Copilot (connect in src/libs/actions/Delegate.ts lines 60–115 or disconnect in lines 117–168), Onyx state is updated/restored for the target account, and Navigation.navigate(ROUTES.HOME) navigates to the Home tab. However, the in-memory navigation state caches in src/libs/Navigation/helpers/lastVisitedTabPathUtils.ts (lastVisitedTabPaths / clearSessionStorage and preserved split navigator states in src/libs/Navigation/AppNavigator/createSplitNavigator/usePreserveNavigatorState.ts) are only cleared during full signOut (src/libs/actions/Session/index.ts), not during Copilot connect or disconnect.
Because the Inbox (REPORTS_SPLIT_NAVIGATOR) split navigator's last visited path and preserved state still hold the previous account's ReportScreen route (reportID), tapping the Inbox tab restores that stale route from memory and triggers OpenReport for the previous account's report.
What changes do you think we should make in order to solve the problem?
- In
src/libs/Navigation/helpers/lastVisitedTabPathUtils.tsandsrc/libs/Navigation/AppNavigator/createSplitNavigator/usePreserveNavigatorState.ts, export a helper (or reuseclearLastVisitedTabPaths/clearPreservedNavigatorStates) that clears all stored tab paths, session storage tab state, and preserved split navigator states across account switches. - In
src/libs/actions/Delegate.ts, inside bothconnectanddisconnect(when switching into a delegator account or returning to the original account), invokeclearLastVisitedTabPaths()and reset the preserved split navigator states before navigating toROUTES.HOMEso that tappingInboxopens the current account's default report rather than the previous account's stalereportID.
What alternative solutions did you explore? (Optional)
We considered checking whether the restored reportID exists in Onyx inside the Inbox tab press handler, but a valid report in the new account might not be loaded in Onyx yet, and clearing the stale navigation state on Copilot account switch directly prevents any cross-account route leakage across all tabs.
📣 @jeffrey-graham! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
@jayeshmangwani
The solution for this issue has been :rocket: deployed to production :rocket: in version 9.5.33-1 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:
- https://github.com/Expensify/App/pull/105911
If no regressions arise, payment will be issued on 2026-11-14. :confetti_ball:
The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
@jayeshmangwani Whoops! This issue is 2 days overdue. Let's get this updated quick!
Contributor+ Checklist:
-
[x] [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: N/A (This is an improvement rather than a regression introduced by a specific PR. The issue already existed for Copilot accounts and has resurfaced now.) Link to the comment on the Issue: N/A
-
[x] [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: I'm not sure if this needs dedicated discussion, as the issue only surfaces in scenarios involving Copilot accounts.
-
[x] [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:
- Log in as Account A, which has permission to Copilot into Account B. Use a wide layout.
Test:
- Go to Account, open the account switcher, and switch to Account B.
- Tap Inbox and verify that a report belonging to Account B opens.
- Go to Account and switch back to Account A.
- Tap Inbox. Verify that a report belonging to Account A opens and that the "Hmm... it's not here" message does not appear.
- Switch to Account B again, tap Inbox, then Home, then Account, and switch back to Account A.
- Press the browser's back button. Verify that the URL changes to
/homeand the Home screen is displayed. - Press the back button again. Verify that the screen matches the URL. Account B's report should open and display "Hmm... it's not here", which is expected because the report belongs to Account B.
- While logged in as Account A, open Spend → Workspaces, then press the browser's back button twice. Verify that each back press displays the screen corresponding to the URL.
- Open a link to your own Concierge chat in a new tab. Go to Account and switch to Account B. Wait 30 seconds.
- Verify that the app stays on the Account screen and does not navigate to the Concierge chat. Then tap Inbox and verify that a report belonging to Account B opens.
Do we agree 👍 or 👎
Triggered auto assignment to @mallenexpensify (Awaiting Payment)
Payment Summary
Resolving PRs:
-
https://github.com/Expensify/App/pull/105911
-
Reviewer: @jayeshmangwani owed $175 via NewDot
-
Contributor: @BartekObudzinski does not require payment (Contractor)
BugZero Checklist (@mallenexpensify)
- [ ] I have confirmed assignees, roles, and Upwork contracts look correct
- [ ] I have paid out Upwork contracts / manual NewDot requests
- [ ] [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
Claude posting on behalf of Matt:
Ready. Job price: $175 (standard, no Help Wanted, assigned 2026-11-04).
- jayeshmangwani (C+): 100%, via NewDot
No deploy blockers or regressions on the issue or the PR.
Next: press Caps+Y, then pay.
Evidence
PAYPREP v1
Payment Summary
Contributor+: @jayeshmangwani due $175 via NewDot
Approved $175 to @jayeshmangwani