[Due for payment 2026-11-25] [$250] Android/iOS-Offline-Navigation arrows disappear after deleted expense syncs online
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: 9.5.5-0 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/App/pull/103109 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Pull Request QA execution Device used: Samsung Galaxy S21/Android 15, iPhone 13/18.6.2 App Component: Other
Action Performed:
- Launch Expensify app
- Log in with valid credentials
- Open Home and make sure the Recently added section shows at least 3 expenses.
- Open dev tools and turn on Force offline.
- Open the first (newest) expense, then select More > Delete.
- Go back to Home and open the expense right under the deleted one.
- Turn off Force offline and wait for the delete to sync, keeping the expense open.
Expected Result:
The deleted expense is removed from Recently added, and the navigation arrows remain visible and allow navigation between expenses that were not deleted.
Actual Result:
After the delete syncs while the expense is open, the navigation arrows disappear.
Workaround:
Unknown
Platforms:
- [x] Android: App
- [ ] Android: mWeb Chrome
- [x] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [ ] Windows: Chrome
- [ ] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/600ae5fe-1a19-4ac9-a757-bb79be71eecc
Applause Internal Information Exported by: Mita Rachim Bug ID: 7280546
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022108002387844305757
- Upwork Job ID: 2108002387844305757
- Last Price Increase: 2026-10-26
Issue Owner
Current Issue Owner: @mallenexpensify
While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/991fcc884615f7f34162ec2bb59523f8cd4800b9fe29cc80ee67921d351a60e3
Proposal
What is the root cause of that problem?
The header remounts while the Test Tools modal covers the expense, and its unmount cleanup wipes the arrow list. The delete sync only coincides with this. Keep pending-delete expenses out of the Recently added carousel did not cause it, and the issue already reproduces in production.
- On native, deleting expense A leaves
nvp_deleteTransactionNavigateBackURLset. The native stack unmounts A's screen right away, which cancels the pending clear inDeleteTransactionNavigateBackHandler.tsx:22-37. - You open expense B, then open Test Tools to turn off Force offline. B loses focus, so B's own handler clears the URL.
ReportNotFoundGuard.tsx:127-131switches from barechildrento<ReportNotFoundInnerGuard>. React then remounts the whole header.- The old navigation component's cleanup in
MoneyRequestReportTransactionsNavigation.tsx:209-217seesTEST_TOOLS_MODAL.ROOTfocused. That screen is not inCAROUSEL_PRESERVING_SCREENS, so the cleanup callsclearActiveTransactionIDs(). - The new component reads an empty list and renders no arrows. Nothing seeds the list again.
Web is not affected because the JS stack keeps the closing screen mounted through the animation, so step 1 clears the URL normally.
What changes do you think we should make in order to solve the problem?
In the unmount cleanup of MoneyRequestReportTransactionsNavigation, skip clearActiveTransactionIDs() while the component's own route key (useRoute().key) is still in the navigation state. If the route is still there, the header remounted inside an open screen and the user did not leave. When the user really leaves, the route is gone from the state, so the list still clears. Use extractNavigationKeys from extractNavigationKeys.ts for the check.
Add a unit test in MoneyRequestReportTransactionsNavigation.test.tsx with a useRoute mock. The test should expect no clear when the route is still in the state while Test Tools is focused.
What alternative solutions did you explore? (Optional)
- Stop
ReportNotFoundGuardfrom changing its root element type, for example by always rendering the inner guard with an enabled flag. This prevents the remount, but the inner guard was split out for performance. - Clear the URL when the deleted screen leaves the stack on native. This fixes the leak, which also disables the deleted-parent "not found" check on the next expense you open. On its own it does not protect the arrows from other remounts.
Confidence and verification
Confidence is medium. This comes from reading the code. It has not been tested on a device, and the web tester can't reproduce a native-only bug. Two predictions would confirm it on Android/iOS:
- After steps 1–6, opening and closing Test Tools without going online also hides the arrows.
- Going online with airplane mode instead of Test Tools keeps the arrows.
The hook itself still returns the right siblings after the sync (useCarouselTransactionIDs.ts:26-47). The list goes empty only because the stored list was cleared.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/103403) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
Triggered auto assignment to Contributor-plus team member for initial proposal review - @shubham1206agra (External)
Job added to Upwork: https://www.upwork.com/jobs/~022108002387844305757
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0163955a2ba22190aa
Proposal
Please re-state the problem that we are trying to solve in this issue.
In Android/iOS, after an expense is deleted while offline, opening an adjacent expense from the carousel and waiting for the offline delete to sync causes the navigation arrows in the header (MoneyRequestReportTransactionsNavigation) to disappear.
What is the root cause of that problem?
-
Unnecessary Component Remounting in
ReportNotFoundGuard.tsx: Insrc/pages/inbox/ReportNotFoundGuard.tsx:127-131:if (!deleteTransactionNavigateBackUrl && isReportTransactionThread(report)) { return <ReportNotFoundInnerGuard reportIDFromPath={routeParams?.reportID}>{children}</ReportNotFoundInnerGuard>; } return children;When an expense is deleted offline,
deleteTransactionNavigateBackUrlis set in Onyx (ONYXKEYS.NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URL). While it is set,ReportNotFoundGuardrenders{children}directly. When the delete syncs andDeleteTransactionNavigateBackHandlerclearsdeleteTransactionNavigateBackUrl,ReportNotFoundGuardswitches from bare{children}to<ReportNotFoundInnerGuard>{children}</ReportNotFoundInnerGuard>. Because the element type changes at the guard root, React unmounts the entire children tree (includingMoneyRequestHeaderandMoneyRequestReportTransactionsNavigation) and mounts a new one. -
Premature Clearing in
MoneyRequestReportTransactionsNavigation.tsx: Insrc/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx:209-217:useEffect(() => { return () => { const focusedRoute = findFocusedRoute(navigationRef.getRootState()); if (focusedRoute?.name && (CAROUSEL_PRESERVING_SCREENS as readonly string[]).includes(focusedRoute.name)) { return; } clearActiveTransactionIDs(); }; }, []);When the unmount cleanup fires:
- If the user has opened the Test Tools modal to toggle offline mode,
findFocusedRoutereturnsTEST_TOOLS_MODAL.ROOT(orSCREENS.RIGHT_MODAL.TEST_TOOLS), which is not inCAROUSEL_PRESERVING_SCREENS. - Checking only
focusedRoute.namefails to distinguish between the user actually navigating away from the screen versus a modal being focused or an internal remount where the screen route is still intact in the navigation state. - Consequently,
clearActiveTransactionIDs()is called, wipingONYXKEYS.TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS. When the re-mountedMoneyRequestReportTransactionsNavigationevaluatesuseCarouselTransactionIDs(),transactionIDsListis empty, causing lines 426-429 to return early and hide the arrows.
- If the user has opened the Test Tools modal to toggle offline mode,
What changes do you think we should make in order to solve the problem?
-
Stabilize
ReportNotFoundGuard.tsxto prevent tree remounts: Instead of conditionally swapping between{children}and<ReportNotFoundInnerGuard>{children}</ReportNotFoundInnerGuard>, always render<ReportNotFoundInnerGuard>for transaction threads and pass a condition (or check!deleteTransactionNavigateBackUrlinternally inReportNotFoundInnerGuardbefore determiningshouldShowNotFoundPage):diff --git a/src/pages/inbox/ReportNotFoundGuard.tsx b/src/pages/inbox/ReportNotFoundGuard.tsx --- a/src/pages/inbox/ReportNotFoundGuard.tsx +++ b/src/pages/inbox/ReportNotFoundGuard.tsx @@ -127,5 +127,9 @@ function ReportNotFoundGuard({children}: ReportNotFoundGuardProps) { - if (!deleteTransactionNavigateBackUrl && isReportTransactionThread(report)) { - return <ReportNotFoundInnerGuard reportIDFromPath={routeParams?.reportID}>{children}</ReportNotFoundInnerGuard>; + if (isReportTransactionThread(report)) { + return ( + <ReportNotFoundInnerGuard + reportIDFromPath={routeParams?.reportID} + shouldCheckParent={!deleteTransactionNavigateBackUrl} + > + {children} + </ReportNotFoundInnerGuard> + ); }In
ReportNotFoundInnerGuard, ifshouldCheckParentisfalse, setshouldShowNotFoundPage = false. This guarantees the component tree never unmounts due todeleteTransactionNavigateBackUrlupdates. -
Harden
MoneyRequestReportTransactionsNavigation.tsxunmount cleanup: Insrc/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx, check whether the component's route key (useRoute().key) is still in the navigation state before clearing:const route = useRoute(); useEffect(() => { return () => { const rootState = navigationRef.getRootState(); const activeKeys = extractNavigationKeys(rootState); if (activeKeys.includes(route.key)) { return; } const focusedRoute = findFocusedRoute(rootState); if (focusedRoute?.name && (CAROUSEL_PRESERVING_SCREENS as readonly string[]).includes(focusedRoute.name)) { return; } clearActiveTransactionIDs(); }; }, [route.key]);Additionally, include
SCREENS.RIGHT_MODAL.TEST_TOOLSinCAROUSEL_PRESERVING_SCREENS.
What alternative solutions did you explore? (Optional)
- Only updating
CAROUSEL_PRESERVING_SCREENS: Does not solve cases where other overlays or transient state transitions cause a remount while the screen route remains alive. Combining route key verification withReportNotFoundGuardstabilization provides complete stability across both native and web platforms.
What specific scenarios should we cover in automated tests?
- In
tests/unit/components/MoneyRequestReportTransactionsNavigation.test.tsx:- Verify that when
MoneyRequestReportTransactionsNavigationunmounts while its route key is still in navigation state (or while a modal is focused),clearActiveTransactionIDsis not called.
- Verify that when
- In
tests/unit/ReportNotFoundGuardTest.tsx:- Verify that toggling
deleteTransactionNavigateBackUrldoes not cause children to unmount and remount.
- Verify that toggling
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~010e53044b5828fe60
Proposal
Please re-state the problem that we are trying to solve in this issue.
In Android/iOS, after an expense is deleted while offline, opening an adjacent expense from the carousel and waiting for the offline delete to sync causes the navigation arrows in the header (MoneyRequestReportTransactionsNavigation) to disappear.
What is the root cause of that problem?
The bug is caused by a race condition between a component tree remount in ReportNotFoundGuard and premature cache clearing in MoneyRequestReportTransactionsNavigation:
-
Tree Remount in
ReportNotFoundGuard.tsx: Insrc/pages/inbox/ReportNotFoundGuard.tsx:127-131:if (!deleteTransactionNavigateBackUrl && isReportTransactionThread(report)) { return <ReportNotFoundInnerGuard reportIDFromPath={routeParams?.reportID}>{children}</ReportNotFoundInnerGuard>; } return children;On native platforms, deleting an expense leaves
deleteTransactionNavigateBackUrlset in Onyx because the native stack immediately unmounts the deleted expense screen, aborting the pending clear inDeleteTransactionNavigateBackHandler. When the user opens a sibling expense from the carousel,deleteTransactionNavigateBackUrlis initially truthy, soReportNotFoundGuardrenders{children}directly. When the user opens Test Tools or the offline action syncs,DeleteTransactionNavigateBackHandlerclearsdeleteTransactionNavigateBackUrl. This causesReportNotFoundGuardto switch from bare{children}to<ReportNotFoundInnerGuard>{children}</ReportNotFoundInnerGuard>. Because the root wrapper component type changes, React completely unmounts the existing{children}tree (includingMoneyRequestHeaderandMoneyRequestReportTransactionsNavigation) and mounts a new one. -
Premature Cache Clearing in
MoneyRequestReportTransactionsNavigation.tsx: Insrc/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx:209-217:useEffect(() => { return () => { const focusedRoute = findFocusedRoute(navigationRef.getRootState()); if (focusedRoute?.name && (CAROUSEL_PRESERVING_SCREENS as readonly string[]).includes(focusedRoute.name)) { return; } clearActiveTransactionIDs(); }; }, []);When the unmount cleanup fires during the tree remount:
findFocusedRouteinspects the top of the stack. If Test Tools or another modal is open, its name is not inCAROUSEL_PRESERVING_SCREENS.- The cleanup assumes the user navigated away from the screen entirely and calls
clearActiveTransactionIDs(), wipingONYXKEYS.TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS. - When the re-mounted
MoneyRequestReportTransactionsNavigationevaluatesuseCarouselTransactionIDs(), the stored IDs list is empty, causing the component to return early and hide the arrows.
What changes do you think we should make in order to solve the problem?
We should apply a two-layer fix to eliminate both the spurious tree remount and the unsafe unmount cleanup:
-
In
src/pages/inbox/ReportNotFoundGuard.tsx: Keep the component structure stable sodeleteTransactionNavigateBackUrlchanges do not unmount and remount{children}:if (isReportTransactionThread(report)) { return ( <ReportNotFoundInnerGuard reportIDFromPath={routeParams?.reportID} shouldCheck={!deleteTransactionNavigateBackUrl} > {children} </ReportNotFoundInnerGuard> ); } return children;Inside
ReportNotFoundInnerGuard, ifshouldCheckisfalse, bypass the parent report action check (settingshouldShowNotFoundPage = false). This guarantees{children}remains mounted without unmounting whendeleteTransactionNavigateBackUrlupdates. -
In
src/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx: Harden the unmount cleanup so it verifies whether the screen's route key is still in the active navigation state usingextractNavigationKeys:const route = useRoute(); useEffect(() => { return () => { const rootState = navigationRef.getRootState(); const activeKeys = extractNavigationKeys(rootState?.routes); // If the route key is still present in the navigation hierarchy, the screen is still active (remount or modal overlay) if (activeKeys.has(route.key)) { return; } const focusedRoute = findFocusedRoute(rootState); if (focusedRoute?.name && (CAROUSEL_PRESERVING_SCREENS as readonly string[]).includes(focusedRoute.name)) { return; } clearActiveTransactionIDs(); }; }, [route.key]);
What specific scenarios should we cover in automated tests?
- In
tests/unit/ReportNotFoundGuardTest.tsx:- Verify that updating
deleteTransactionNavigateBackUrlfrom a URL tonulldoes not trigger an unmount/remount ofchildren.
- Verify that updating
- In
tests/unit/components/MoneyRequestReportTransactionsNavigation.test.tsx:- Verify that when
MoneyRequestReportTransactionsNavigationunmounts while its route key exists inextractNavigationKeys,clearActiveTransactionIDsis not invoked. - Verify that when the route key is removed from navigation state,
clearActiveTransactionIDsis called as expected.
- Verify that when
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Android/iOS, when an expense is deleted while offline and the user opens an adjacent expense from the carousel, opening SCREENS.TEST_TOOLS_MODAL.ROOT (or waiting for the delete to sync online) causes the header navigation arrows to disappear.
What is the root cause of that problem?
The root cause consists of two intertwined issues in ReportNotFoundGuard and MoneyRequestReportTransactionsNavigation:
-
Unnecessary Component Remounting in
ReportNotFoundGuard.tsx: On native, deleting the first expense setsONYXKEYS.NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URL, and popping the deleted screen unmountssrc/pages/inbox/DeleteTransactionNavigateBackHandler.tsx#L22-L37(handle.cancel()) before the deferred clear runs. When the adjacent expense is opened,src/pages/inbox/ReportNotFoundGuard.tsx#L127-L131conditionally wraps{children}in<ReportNotFoundInnerGuard>only when!deleteTransactionNavigateBackUrl && isReportTransactionThread(report). WhiledeleteTransactionNavigateBackUrlis set, it renders bare{children}. As soon asSCREENS.TEST_TOOLS_MODAL.ROOT(or any overlay/edit modal) opens over the expense and blurs it,DeleteTransactionNavigateBackHandlerclearsdeleteTransactionNavigateBackUrl, switching the returned JSX element from{children}to<ReportNotFoundInnerGuard>{children}</ReportNotFoundInnerGuard>. In React's reconciliation engine, changing the wrapper component type destroys and remounts the entire subtree, unmountingMoneyRequestReportTransactionsNavigation. -
Premature Cache Eviction in
MoneyRequestReportTransactionsNavigation.tsx: During unmount, the cleanup effect insrc/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx#L211-L219checksfindFocusedRoute(navigationRef.getRootState())againstCAROUSEL_PRESERVING_SCREENS. BecauseSCREENS.TEST_TOOLS_MODAL.ROOT(or another overlay modal) is focused, it concludes navigation has exited the screen and unconditionally invokesclearActiveTransactionIDs(), wipingONYXKEYS.TRANSACTION_THREAD_NAVIGATION_TRANSACTION_IDS. When the component remounts, the carousel transaction ID list in Onyx is empty, causing the component to render nothing and hiding the navigation arrows.
What changes do you think we should make in order to solve the problem?
-
In
src/pages/inbox/ReportNotFoundGuard.tsx#L127-L164: Stabilize the component hierarchy so that updatingdeleteTransactionNavigateBackUrldoes not alter the wrapper component structure. Always renderReportNotFoundInnerGuardwhenisReportTransactionThread(report)is true and pass a boolean prop (shouldCheckParent={!deleteTransactionNavigateBackUrl}) intoReportNotFoundInnerGuard. WhenshouldCheckParentis false, skip the parent report action not-found gate (shouldShowNotFoundPage = shouldCheckParent && (isParentActionDeleted || isParentActionMissingAfterLoad)). Non-thread reports continue returningchildrendirectly, while transaction threads never unmount{children}whendeleteTransactionNavigateBackUrlclears underSCREENS.TEST_TOOLS_MODAL.ROOTor any other modal. -
In
src/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx#L211-L219: Harden the unmount cleanup hook so it does not clear transaction IDs while the hosting report screen remains mounted in navigation state. Capture the hosting route key viaconst route = useContext(NavigationRouteContext)and checkextractNavigationKeys(navigationRef.getRootState()).has(route.key)in the unmount cleanup before callingclearActiveTransactionIDs(). Only executeclearActiveTransactionIDs()when the route has truly been removed from navigation state (and not preserved byCAROUSEL_PRESERVING_SCREENS).
What alternative solutions did you explore? (Optional)
- Only adding
SCREENS.TEST_TOOLS_MODAL.ROOT/SCREENS.TEST_TOOLS_MODAL.SERVERtoCAROUSEL_PRESERVING_SCREENS: While that masks the Test Tools repro, it does not prevent the fullReportScreenunmount/remount cycle inReportNotFoundGuardwhendeleteTransactionNavigateBackUrlclears, and any other overlay screen pushed over the expense (such as editing Description/Amount or viewing Receipt attachments) still wipes the arrows. StabilizingReportNotFoundGuardand guarding unmount cleanup by route presence fixesSCREENS.TEST_TOOLS_MODAL.ROOTand every overlay screen cleanly.
What specific scenarios should we cover in automated tests?
- In
tests/unit/ReportNotFoundGuardTest.tsx:
- Verify that transitioning
deleteTransactionNavigateBackUrlfrom a non-empty string toundefined/nullon a transaction thread maintains component stability without unmountingchildren.
- In
tests/unit/components/MoneyRequestReportTransactionsNavigation.test.tsx:
- Verify that unmounting while
SCREENS.TEST_TOOLS_MODAL.ROOTis focused and the hosting route key remains in navigation state does not callclearActiveTransactionIDs. - Verify that navigating away (hosting route key removed from navigation state) still calls
clearActiveTransactionIDs.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0139ed4098bdc50182
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
@shubham1206agra
While testing this issue locally, I noticed an important finding regarding the root cause that contradicts the original issue description:
The issue description states that the navigation arrows disappear after the offline delete syncs online. However, as shown in the attached recording and screenshot, the delete sync has nothing to do with it. The navigation arrows disappear the exact moment the Dev Tools drawer opens on top of the expense, while the app is still completely offline.
Screenshot demonstrating this exact behavior:
Video demonstrating this exact behavior:
https://github.com/user-attachments/assets/1e74a129-11d0-490b-9763-0c7b40b14861
This happens because opening an overlay modal causes the underlying expense screen to lose focus, which triggers an unnecessary component unmount/remount in the report guard and prematurely clears the cached carousel transaction IDs.
I have already tested and verified a clean, two-layer solution that:
- Prevents the unwanted screen unmount/remount when focus changes.
- Hardens the carousel unmount cleanup to avoid wiping navigation state while the screen remains active in navigation.
Would you like me to submit the full proposal for review?
Video showing the working fix:
https://github.com/user-attachments/assets/208c4ee8-98e6-4acc-a752-3fa0a0994420
@shubham1206agra Huh... This is 4 days overdue. Who can take care of this?
@shubham1206agra 6 days overdue. This is scarier than being forced to listen to Vogon poetry!
@MelvinBot Try to focus the fix wrt TEST_TOOLS_MODAL.ROOT screen as shown here too https://github.com/Expensify/App/issues/103403#issuecomment-6084642140
Proposal (updated, focused on TEST_TOOLS_MODAL.ROOT)
Please re-state the problem that we are trying to solve in this issue.
On Android/iOS, the expense navigation arrows disappear when you open Test Tools over an expense right after deleting another expense offline.
What is the root cause of that problem?
The delete sync is not the trigger. As emkhalid showed in this comment, the arrows vanish the moment Test Tools opens, while still offline.
- On native, the deleted expense's screen unmounts before it clears
nvp_deleteTransactionNavigateBackURL, so the URL is left set (DeleteTransactionNavigateBackHandler.tsx:22-37). - Opening Test Tools pushes
SCREENS.TEST_TOOLS_MODAL.ROOTover the expense. The expense loses focus, and its handler clears the URL. ReportNotFoundGuard.tsx:127-131then wraps its children inReportNotFoundInnerGuard, which remounts the header.- The old carousel's unmount cleanup sees
TEST_TOOLS_MODAL.ROOTfocused. That screen is not inCAROUSEL_PRESERVING_SCREENS, so the cleanup callsclearActiveTransactionIDs(). The remounted carousel finds an empty list and renders no arrows.
What changes do you think we should make in order to solve the problem?
Add SCREENS.TEST_TOOLS_MODAL.ROOT and SCREENS.TEST_TOOLS_MODAL.SERVER to CAROUSEL_PRESERVING_SCREENS in MoneyRequestReportTransactionsNavigation.tsx.
Test Tools is a debug overlay. It never ends the expense-navigation flow, and closing it returns to the same expense screen. So a carousel teardown while Test Tools is focused must keep the list. SERVER is included because you can reach it from the Test Tools menu.
What specific scenarios should we cover in automated tests?
In tests/unit/components/MoneyRequestReportTransactionsNavigation.test.tsx, add both screens to the existing keeps the active transaction IDs when unmounting onto %s table.
What alternative solutions did you explore? (Optional)
- Skip the clear while the component's own route key is still in the navigation state. This was my earlier proposal. It covers any overlay, but it changes more behavior than this bug needs.
- Always render
ReportNotFoundInnerGuardwith an enabled flag so the header never remounts. This removes the remount, but it changes the guard that was split out for performance.
Confidence and side effects
Confidence is medium. This comes from reading the code and matches the Android recording in the linked comment. I did not test it on a device. Web is not affected, because the JS stack clears the URL normally in step 1, so the web tester can't reproduce it.
The change only affects teardown while Test Tools is focused. If the list is kept when it should not be, nothing breaks: the carousel renders nothing when the current expense is not in the list, and the next carousel overwrites the list.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/103403) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
@MelvinBot Try to focus the fix wrt
TEST_TOOLS_MODAL.ROOTscreen as shown here too #103403 (comment)
Comment By human and no automation!
@shubham1206agra
Thanks for looking into my finding! Before moving forward with MelvinBot's updated proposal, I wanted to point out a key limitation with that approach:
Adding TEST_TOOLS_MODAL to CAROUSEL_PRESERVING_SCREENS as in Melvin proposal is just a temporary band-aid:
- It only handles Test Tools. If a user opens any other drawer, modal, or overlay over the expense, the screen still loses focus and the arrows disappear again.
- It doesn't address the real bug:
ReportNotFoundGuardis still unmounting and remounting the entire report screen when focus changes.
The proper fix is much simpler and directly targets the root cause in ReportNotFoundGuard.tsx:127-131:
https://github.com/Expensify/App/blob/ef784ba78226f211bbaa5d6698a5a162c20221e9/src/pages/inbox/ReportNotFoundGuard.tsx#L127-L131
Instead of conditionally swapping wrapper component types, keep ReportNotFoundInnerGuard mounted for transaction threads and pass shouldCheckParentAction={!deleteTransactionNavigateBackUrl}:
if (isReportTransactionThread(report)) {
return (
<ReportNotFoundInnerGuard
reportIDFromPath={routeParams?.reportID}
shouldCheckParentAction={!deleteTransactionNavigateBackUrl}
>
{children}
</ReportNotFoundInnerGuard>
);
}
return children;
And in ReportNotFoundInnerGuard:
const shouldShowNotFoundPage = shouldCheckParentAction && (isParentActionDeleted || isParentActionMissingAfterLoad);
This clean 4-line change stops the entire screen from remounting, avoids polluting carousel screens with debug modal names, and permanently fixes the issue for all modals.
I've already implemented and validated this locally (as shown in my previous fix video). If this approach looks good to you, I can post the full proposal so you can review it and we can get this resolved cleanly.
:sos: C+ Help Wanted
Proposal
What is the root cause of that problem?
The sync does not remove the arrows. The expense screen remounts while another screen covers it, and the carousel's unmount cleanup wipes the sibling list.
- Deleting an expense sets
nvp_deleteTransactionNavigateBackURL, so the closing thread does not flash "not found". Its handler clears the URL only after the closing transition and cancels that on unmount, so on native the URL can still be set when the next expense is opened from Home:
https://github.com/Expensify/App/blob/f8bb9886c921b49056f054ead83d0f90d6257502/src/pages/inbox/DeleteTransactionNavigateBackHandler.tsx#L22-L37
- When that expense loses focus (Test Tools, or any page opened on top such as Description), its own handler clears the URL.
ReportNotFoundGuardthen stops returning barechildrenand wraps them inReportNotFoundInnerGuard. The element type changes, so React remounts the whole report subtree, header included:
https://github.com/Expensify/App/blob/f8bb9886c921b49056f054ead83d0f90d6257502/src/pages/inbox/ReportNotFoundGuard.tsx#L127-L131
- The old carousel's cleanup runs during that remount. The focused route is the covering screen, not a carousel screen, so it calls
clearActiveTransactionIDs():
https://github.com/Expensify/App/blob/f8bb9886c921b49056f054ead83d0f90d6257502/src/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx#L209-L217
- The remounted header reads an empty list and renders no arrows, and nothing seeds it again:
https://github.com/Expensify/App/blob/f8bb9886c921b49056f054ead83d0f90d6257502/src/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx#L432-L437
I did not reproduce this on Android/iOS yet. I seeded nvp_deleteTransactionNavigateBackURL on an open expense on dev web and measured the carousel: opening Test Tools cleared the URL, and 21 ms later that cleanup set transactionThreadNavigationTransactionIDs to null. The arrows stayed gone after closing it, and opening Description did the same.
What changes do you think we should make in order to solve the problem?
Keep the guard's tree stable: always render ReportNotFoundInnerGuard for a transaction thread, and move the URL check into its not-found condition.
- if (!deleteTransactionNavigateBackUrl && isReportTransactionThread(report)) {
+ if (isReportTransactionThread(report)) {
return <ReportNotFoundInnerGuard reportIDFromPath={routeParams?.reportID}>{children}</ReportNotFoundInnerGuard>;
...
const parentReportAction = useParentReportAction(report);
+ const [deleteTransactionNavigateBackUrl] = useOnyx(ONYXKEYS.NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URL);
...
- const shouldShowNotFoundPage = isParentActionDeleted || isParentActionMissingAfterLoad;
+ const shouldShowNotFoundPage = !deleteTransactionNavigateBackUrl && (isParentActionDeleted || isParentActionMissingAfterLoad);
Clearing the URL then no longer swaps the wrapper, so an open expense is never remounted under another screen.
With the change, the same seeded steps keep both arrows after Test Tools and after Description. Going back to Home still clears the list, and deleting still returns to Home with no "not found" flash.
What alternative solutions did you explore? (Optional)
- Skip the clear while the cleanup's route key is still in the navigation state: the screen still remounts, and two existing tests render it without a navigator.
- Clear the URL when the deleted screen unmounts: fixes only this trigger, not later URL changes.
Proposal
What is the root cause of that problem?
The arrows don't disappear because PR #103109 filtered the deleted row — that filter is working. Opening an expense from Home "Recently added" seeds the carousel with every sibling ID and hides only the pending-delete one, so [A, B, C] becomes [B, C] (useCarouselTransactionIDs.ts#L26-L47). Two entries is still enough to render arrows (MoneyRequestReportTransactionsNavigation.tsx#L435-L437). They vanish only because the whole seeded list gets wiped. Here's the chain:
- Home seeds the carousel (source
home:recentlyAdded) and opens the expense onSEARCH_REPORT(RecentlyAddedSection/index.tsx#L92-L97). The whole report screen — header, actions, footer — renders insideReportNotFoundGuard(ReportScreen.tsx#L128-L165). - Because you deleted the previous expense offline, the global
NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URLis still set. While it's set, the guard returns the report body as barechildren(ReportNotFoundGuard.tsx#L127-L131). - Opening Test Tools unfocuses the expense, so its handler clears that URL after the transition settles (
DeleteTransactionNavigateBackHandler.tsx#L22-L37). - The instant the URL clears, the guard's return flips from bare
childrento<ReportNotFoundInnerGuard>{children}</ReportNotFoundInnerGuard>(L127-L131). The element type at that slot changes, so React tears down the entirechildrensubtree and mounts a new one. - In that teardown, the carousel component's unmount effect runs. It clears the list unless the focused route is in
CAROUSEL_PRESERVING_SCREENS(MoneyRequestReportTransactionsNavigation.tsx#L209-L217, list at L38-L43). With Test Tools focused, the focused route isRIGHT_MODAL.TEST_TOOLS— not in the list — so it callsclearActiveTransactionIDs(). - The newly-mounted header reads an empty list, hits
transactionIDsList.length < 2, and renders nothing. Nothing re-seeds, so the arrows are gone for good.
The true defect is the element-type swap at L127-L131. The outer guard already folds deleteTransactionNavigateBackUrl into its own not-found decision (L79); the bare-children branch exists only to suppress the inner guard's parent-deletion check during the back-navigation, and it pays for that with a full remount of the report screen every time the URL toggles. Web is unaffected because the deleted expense's screen stays mounted through its close animation, so step 2's URL never leaks past the delete.
What changes do you think we should make in order to solve the problem?
Fix layer: render — ReportNotFoundGuard. Keep the element type at that slot stable so the report body never remounts when the URL toggles. Always render the inner guard for transaction threads and let it no-op its check while the URL is set, instead of swapping to bare children:
// ReportNotFoundGuard.tsx — stop swapping the wrapper component
if (isReportTransactionThread(report)) {
return (
<ReportNotFoundInnerGuard reportIDFromPath={routeParams?.reportID} isActive={!deleteTransactionNavigateBackUrl}>
{children}
</ReportNotFoundInnerGuard>
);
}
return children;
// ReportNotFoundInnerGuard — gate the parent-deletion check on isActive (default true)
const shouldShowNotFoundPage = isActive && (isParentActionDeleted || isParentActionMissingAfterLoad);
Now toggling the URL only flips a prop. children stay mounted, the carousel component never unmounts, clearActiveTransactionIDs() never fires, and — as a bonus — the whole report view stops rebuilding on every offline-delete sync.
Race-free: this removes the remount structurally (stable element type), so there's no ordering between "URL clears" and "teardown fires." A teardown-side guard only narrows when the clear is safe; the subtree still remounts.
On the perf split: ReportNotFoundInnerGuard was separated so non-transaction-thread reports don't subscribe to the expensive parent keys. That still holds — I only always-mount it for transaction threads, which already mount it the instant the URL clears. The sole change is it stays mounted through the brief URL-set window instead of mounting a beat later; no additional reports start subscribing.
Verification: I read the code at 4bb6832 but couldn't run Jest — this checkout has no node_modules, so numbers below are the suites that constrain the change, not a run. The "clearing the carousel on unmount" block in tests/unit/components/MoneyRequestReportTransactionsNavigation.test.tsx (preserved screens → no clear; unrelated screen → clear) stays green because I don't touch that effect at all. For the fix itself, add a case to tests/unit/ReportNotFoundGuardTest.tsx: wrap a probe that counts its mounts, toggle NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URL from a URL to null, and assert the probe mounts once — it mounts twice on main.
What alternative solutions did you explore? (Optional)
- Clear
NVP_DELETE_TRANSACTION_NAVIGATE_BACK_URLwhen the deleted expense's screen leaves the native stack (fix the leak at the source). Rejected: the leak is only one trigger — any future element-type change in this guard reintroduces the remount — and clearing the URL too eagerly brings back the not-found flash the URL exists to prevent. - Hardening the unmount cleanup so the clear survives a remount is a real improvement, but it treats the symptom and leaves the full report-screen rebuild in place; another contributor has taken that route.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Android/iOS, after deleting one expense offline and opening the next one, the prev/next arrows disappear from the open expense once the delete syncs. The arrows should stay and page between the expenses that are left.
What is the root cause of that problem?
The delete sync doesn't hide the arrows. Opening Test Tools to turn Force offline off does, because Test Tools blurs the expense screen and that sets off an unmount cleanup that assumes the user has left the expense.
On native, the deleted expense's screen unmounts before its deferred clear runs, and the cleanup cancels that clear. That leaves nvp_deleteTransactionNavigateBackURL set:
https://github.com/Expensify/App/blob/adb2c0217dceb9f5ac7fe6cced904ef0ebd87440/src/pages/inbox/DeleteTransactionNavigateBackHandler.tsx#L22-L37
When Test Tools opens over expense B, B loses focus and its own handler clears the URL. ReportNotFoundGuard then stops returning children directly and wraps them in ReportNotFoundInnerGuard. React sees a different tree, so the header remounts:
https://github.com/Expensify/App/blob/adb2c0217dceb9f5ac7fe6cced904ef0ebd87440/src/pages/inbox/ReportNotFoundGuard.tsx#L127-L131
The old carousel's cleanup only checks the focused route name against CAROUSEL_PRESERVING_SCREENS. TEST_TOOLS_MODAL.ROOT isn't on that list, so it wipes the list even though B's route is still in the stack under the modal:
https://github.com/Expensify/App/blob/adb2c0217dceb9f5ac7fe6cced904ef0ebd87440/src/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx#L209-L217
https://github.com/Expensify/App/blob/adb2c0217dceb9f5ac7fe6cced904ef0ebd87440/src/libs/actions/TransactionThreadNavigation.ts#L179-L189
The remounted carousel then has fewer than two IDs and renders nothing:
https://github.com/Expensify/App/blob/adb2c0217dceb9f5ac7fe6cced904ef0ebd87440/src/components/MoneyRequestReportView/MoneyRequestReportTransactionsNavigation.tsx#L437-L439
I rebuilt that moment in a test: Test Tools focused, the expense route still nested in the RHP, and the header rewrapped like the guard does.
- Root state at teardown:
RightModalNavigator > SEARCH_REPORT (report-route-key), withTestToolsModalNavigator > TEST_TOOLS_MODAL.ROOTfocused on top. findFocusedRoutereturnsTEST_TOOLS_MODAL.ROOT, and it's not in the allowlist.clearActiveTransactionIDsfired once on that remount (expected 0, got 1), while the screen that owns the carousel never left.
flowchart TD
A["Delete expense A offline, open expense B"] -->|"A unmounts, deferred clear cancelled"| B["deleteTransactionNavigateBackURL stays set"]
B -->|"Test Tools opens, B blurs"| C["B's handler clears the URL"]
C -->|"guard wraps children in ReportNotFoundInnerGuard"| D["Header remounts, B's route still in the stack"]
D -->|"focused route TEST_TOOLS_MODAL.ROOT not allowlisted"| E["clearActiveTransactionIDs fires"]
E -->|"transactionIDsList.length < 2"| F["Arrows gone"]
What changes do you think we should make in order to solve the problem?
The cleanup should tell an internal remount apart from actually leaving the expense. The carousel already sits inside the report screen, so it can capture its own useRoute().key. On unmount, if that key is still anywhere in navigationRef.getRootState(), the user hasn't left, and the list stays. The existing helper already walks nested states, which matters because the report route sits under the modal navigator:
https://github.com/Expensify/App/blob/adb2c0217dceb9f5ac7fe6cced904ef0ebd87440/src/libs/Navigation/helpers/extractNavigationKeys.ts#L10-L35
+ const {key: routeKey} = useRoute();
...
return () => {
- const focusedRoute = findFocusedRoute(navigationRef.getRootState());
+ const rootState = navigationRef.getRootState();
+ if (extractNavigationKeys(rootState?.routes).has(routeKey)) {
+ return;
+ }
+ const focusedRoute = findFocusedRoute(rootState);
if (focusedRoute?.name && (CAROUSEL_PRESERVING_SCREENS as readonly string[]).includes(focusedRoute.name)) {
return;
}
clearActiveTransactionIDs();
};
- }, []);
+ }, [routeKey]);
The CAROUSEL_PRESERVING_SCREENS check stays as it is for the case it was written for: the expense route is gone but the user is still inside the carousel flow (#90366). Going back from the expense removes its route key, so every real exit still reaches clearActiveTransactionIDs().
I ran this against the same setup. With the fix, the remount under Test Tools no longer clears the list. When the expense route itself is gone while Test Tools is focused, it still clears. I added both cases to MoneyRequestReportTransactionsNavigation.test.tsx. The first one fails on current main and passes with the change, and the existing allowlist and unrelated-screen tests still pass.
What alternative solutions did you explore? (Optional)
Adding TEST_TOOLS_MODAL.ROOT and SERVER to CAROUSEL_PRESERVING_SCREENS makes this one repro go away. But the bug isn't really about Test Tools. Any modal outside the list that blurs the expense while that stale URL is set causes the same rewrap and the same wipe, and the allowlist would need another entry each time someone finds one. It also changes the wrong thing: it keeps the list whenever Test Tools is focused, even if the expense route has really gone. The route-key check only skips the clear when the screen that owns the carousel is provably still mounted.
Always mounting ReportNotFoundInnerGuard behind a flag would stop the remount too. That would undo the split that keeps parentReportAction subscriptions off non-thread report screens, so I'd rather leave the guard alone.
https://github.com/user-attachments/assets/8269f30c-6d6e-4e75-a83e-82f6fb10fb90
https://github.com/user-attachments/assets/f7c8dfce-05d3-4c16-8696-b0c57559d205