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-05-11] [$500] DM chat cannot be exited after deleting an expense and tapping back button #88499
Version Number: 9.3.61-0 Reproducible in staging?: Yes Reproducible in production?: No If this was caught during regression testing, add the test name, ID and link from BrowserStack:#88053 Email or phone of affected tester (no customers): N/A Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: iPhone 15 iOS 26,3,1 App Component: Money Requests
Action Performed:
Sign in to ND with a new account
Create a 1:1 chat with another user
Create an expense in the chat
Open the expense and tap the parent chat link in the header
Tap the expense again, tap “More options,” and then tap “Delete.”
Tap Back button
Expected Result:
User is able to navigate away from the chat after deleting an expense
Actual Result:
User is stuck in the DM chat. On Prod the app crashes
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Identify the pull request that introduced this issue and revert it.
The delete-expense flow in MoneyRequestHeaderSecondaryActions (line 438-450) calls onBackButtonPress() synchronously and defers the actual deletion via InteractionManager.runAfterInteractions. This leaves stale navigation stack entries for the deleted report. When the user taps back from the DM, they navigate to one of these stale entries.
The safety mechanisms that should handle this scenario all fail:
deleteTransactionNavigateBackUrl suppresses the NotFound guard (ReportNotFoundGuard.tsx:54): The URL is set before deletion and only cleared by DeleteTransactionNavigateBackHandler when its host screen loses focus. The DM screen is focused after the delete, so it doesn't clear the URL. When the user navigates backward to the deleted report, the URL is still set, suppressing the NotFound page.
isOptimisticDelete permanently hides the deleted transaction thread: The transaction thread gets statusNum: CLOSED during optimistic deletion (DeleteMoneyRequest.ts), making isOptimisticDelete = true. In ReportNotFoundGuard.tsx:51, reportExists = !!reportID || isOptimisticDelete || userLeavingStatus evaluates to true even though reportID is null. This was designed to prevent a brief NotFound flash during the deletion transition, but it also prevents NotFound from ever showing when the user navigates back to the deleted screen.
useReportWasDeleted can't detect already-deleted reports (useReportWasDeleted.ts:56): The isOptimisticDelete guard causes an early return, so wasDeleted stays false. The "Navigate on deletion" effect in ReportNavigateAwayHandler.tsx:187-209 never fires.
"Navigate on removal" skips first render (ReportNavigateAwayHandler.tsx:129): When the stale screen remounts, firstRender.current = true causes the effect to skip, and on second render prevOnyxReportID was undefined (from the loading state), so wasReportRemoved is false.
The user ends up on a screen showing a deleted report with all escape mechanisms bypassed, making the back button non-functional or causing a crash (on prod).
PR #88053 exacerbated this by changing MoneyRequestReportActionsList to source reportID from route.params instead of props. This means the component maintains its Onyx subscription to the deleted report key (REPORT_{id}) even after the report's reportID is set to null, causing it to operate on a partially-deleted object with a forced type cast hiding the undefined state (line 101: as unknown as [OnyxTypes.Report]).
What changes do you think we should make in order to solve the problem?
Fix the ReportNotFoundGuard to not treat isOptimisticDelete as proof of report existence when the reportID is null AND deleteTransactionNavigateBackUrl has been cleared (or is absent). This makes the NotFound page show correctly for stale navigation entries while still preventing the flash during active deletion:
This ties the isOptimisticDelete suppression to the active deletion flow (indicated by deleteTransactionNavigateBackUrl being set). Once the URL is cleared (after the deletion transition completes), a deleted report with statusNum: CLOSED and reportID: null will correctly show the NotFound page, allowing the user to navigate away.
What alternative solutions did you explore? (Optional)
Clean stale entries from navigation stack on deletion: More invasive — would require deleteMoneyRequest to inspect and manipulate the React Navigation state, which couples deletion logic to navigation internals.
Make useReportWasDeleted detect already-deleted reports on mount: Would require removing the isOptimisticDelete early return, but this could reintroduce the NotFound flash that the flag was designed to prevent.
Clear deleteTransactionNavigateBackUrl more aggressively (e.g., on a timer): Fragile and timing-dependent; doesn't fix the isOptimisticDelete permanently hiding deleted reports.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
PR #88053 exacerbated this by changing MoneyRequestReportActionsList to source reportID from route.params instead of props. This means the component maintains its Onyx subscription to the deleted report key (REPORT_{id}) even after the report's reportID is set to null, causing it to operate on a partially-deleted object with a forced type cast hiding the undefined state (line 101: as unknown as [OnyxTypes.Report]).
You're right — I retract the claim about PR #88053. The reportExists check at ReportNotFoundGuard.tsx:47-51 uses report?.reportID from Onyx, not route params, and the same was true in the old ReportScreen.tsx. The change to route-sourced reportID in MoneyRequestReportActionsList doesn't affect this guard.
The rest of the analysis still holds: the core issue is that stale navigation stack entries for deleted reports aren't properly caught. Specifically:
deleteTransactionNavigateBackUrl suppresses the outer NotFound guard (ReportNotFoundGuard.tsx:54) and prevents the inner guard from running (line 100: !deleteTransactionNavigateBackUrl && isReportTransactionThread(report)). The URL persists because DeleteTransactionNavigateBackHandler only clears it when its host screen loses focus.
For transaction threads, isOptimisticDelete (statusNum === CLOSED) makes reportExists = true at line 51, so even after the URL is cleared, the outer guard doesn't fire. The inner guard (ReportNotFoundInnerGuard) should then catch it via isParentActionDeleted, but only once the URL is cleared.
I've updated my proposal above to remove the PR #88053 claim. The recommended fix at line 51 remains the same — tying isOptimisticDelete to the active deletion window:
This ensures that once the deletion transition completes (URL cleared), a deleted report with statusNum: CLOSED and reportID: null falls through to the inner guard for transaction threads, or shows NotFound directly for other report types.
Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.
[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: Can't find out exactly the offending PR. I guess that it's mixed up while refactoring the navigation system
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.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Activity
melvin-bot commentedon Apr 22, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #88053
melvin-bot commentedon Apr 22, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Apr 22, 2026
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
MelvinBot commentedon Apr 22, 2026
Proposal
What is the root cause of that problem?
The delete-expense flow in
MoneyRequestHeaderSecondaryActions(line 438-450) callsonBackButtonPress()synchronously and defers the actual deletion viaInteractionManager.runAfterInteractions. This leaves stale navigation stack entries for the deleted report. When the user taps back from the DM, they navigate to one of these stale entries.The safety mechanisms that should handle this scenario all fail:
deleteTransactionNavigateBackUrlsuppresses the NotFound guard (ReportNotFoundGuard.tsx:54): The URL is set before deletion and only cleared byDeleteTransactionNavigateBackHandlerwhen its host screen loses focus. The DM screen is focused after the delete, so it doesn't clear the URL. When the user navigates backward to the deleted report, the URL is still set, suppressing the NotFound page.isOptimisticDeletepermanently hides the deleted transaction thread: The transaction thread getsstatusNum: CLOSEDduring optimistic deletion (DeleteMoneyRequest.ts), makingisOptimisticDelete = true. InReportNotFoundGuard.tsx:51,reportExists = !!reportID || isOptimisticDelete || userLeavingStatusevaluates totrueeven thoughreportIDis null. This was designed to prevent a brief NotFound flash during the deletion transition, but it also prevents NotFound from ever showing when the user navigates back to the deleted screen.useReportWasDeletedcan't detect already-deleted reports (useReportWasDeleted.ts:56): TheisOptimisticDeleteguard causes an early return, sowasDeletedstaysfalse. The "Navigate on deletion" effect inReportNavigateAwayHandler.tsx:187-209never fires."Navigate on removal" skips first render (
ReportNavigateAwayHandler.tsx:129): When the stale screen remounts,firstRender.current = truecauses the effect to skip, and on second renderprevOnyxReportIDwas undefined (from the loading state), sowasReportRemovedisfalse.The user ends up on a screen showing a deleted report with all escape mechanisms bypassed, making the back button non-functional or causing a crash (on prod).
PR #88053 exacerbated this by changing
MoneyRequestReportActionsListto sourcereportIDfromroute.paramsinstead of props. This means the component maintains its Onyx subscription to the deleted report key (REPORT_{id}) even after the report'sreportIDis set tonull, causing it to operate on a partially-deleted object with a forced type cast hiding theundefinedstate (line 101:as unknown as [OnyxTypes.Report]).What changes do you think we should make in order to solve the problem?
Fix the
ReportNotFoundGuardto not treatisOptimisticDeleteas proof of report existence when thereportIDis null ANDdeleteTransactionNavigateBackUrlhas been cleared (or is absent). This makes the NotFound page show correctly for stale navigation entries while still preventing the flash during active deletion:In
ReportNotFoundGuard.tsx:51, change:to:
This ties the
isOptimisticDeletesuppression to the active deletion flow (indicated bydeleteTransactionNavigateBackUrlbeing set). Once the URL is cleared (after the deletion transition completes), a deleted report withstatusNum: CLOSEDandreportID: nullwill correctly show the NotFound page, allowing the user to navigate away.What alternative solutions did you explore? (Optional)
deleteMoneyRequestto inspect and manipulate the React Navigation state, which couples deletion logic to navigation internals.useReportWasDeleteddetect already-deleted reports on mount: Would require removing theisOptimisticDeleteearly return, but this could reintroduce the NotFound flash that the flag was designed to prevent.deleteTransactionNavigateBackUrlmore aggressively (e.g., on a timer): Fragile and timing-dependent; doesn't fix theisOptimisticDeletepermanently hiding deleted reports.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.DylanDylann commentedon Apr 22, 2026
@MelvinBot Before moving the logic to
ReportNotFoundGuardcomponent in #86720. We also usereportIDfromreportin src/pages/inbox/ReportScreen.tsxSo I don't think your statement is valid
MelvinBot commentedon Apr 22, 2026
You're right — I retract the claim about PR #88053. The
reportExistscheck atReportNotFoundGuard.tsx:47-51usesreport?.reportIDfrom Onyx, not route params, and the same was true in the oldReportScreen.tsx. The change to route-sourced reportID inMoneyRequestReportActionsListdoesn't affect this guard.The rest of the analysis still holds: the core issue is that stale navigation stack entries for deleted reports aren't properly caught. Specifically:
deleteTransactionNavigateBackUrlsuppresses the outer NotFound guard (ReportNotFoundGuard.tsx:54) and prevents the inner guard from running (line 100: !deleteTransactionNavigateBackUrl && isReportTransactionThread(report)). The URL persists becauseDeleteTransactionNavigateBackHandleronly clears it when its host screen loses focus.For transaction threads,
isOptimisticDelete(statusNum === CLOSED) makesreportExists = trueat line 51, so even after the URL is cleared, the outer guard doesn't fire. The inner guard (ReportNotFoundInnerGuard) should then catch it viaisParentActionDeleted, but only once the URL is cleared.I've updated my proposal above to remove the PR #88053 claim. The recommended fix at line 51 remains the same — tying
isOptimisticDeleteto the active deletion window:This ensures that once the deletion transition completes (URL cleared), a deleted report with
statusNum: CLOSEDandreportID: nullfalls through to the inner guard for transaction threads, or shows NotFound directly for other report types.Next Steps: Reply with
@MelvinBot <your feedback>to refine this analysis.55 remaining items
DylanDylann commentedon May 6, 2026
BugZero 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: Can't find out exactly the offending PR. I guess that it's mixed up while refactoring the navigation system
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.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue: https://github.com/Expensify/Expensify/issues/635925
Regression Test Proposal
Test:
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-f47a-ab6c-786e-0335c49794c4melvin-bot commentedon May 10, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon May 11, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon May 12, 2026
Payment Summary
Contributor: @truph01 due $500 via NewDot
Contributor+: @DylanDylann due $500 via NewDot
^ Test case created
Thx
quinthar commentedon May 30, 2026
Approved $500 to @DylanDylann
garrettmknight commentedon Jul 10, 2026
$500 approved for @truph01