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-01] Web - Expense - Back button does not trigger discard change modal on Description #102010
👋 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.
goUp() now dispatches the same back action twice, and the second dispatch immediately closes the discard prompt the first one opened. Nothing merged on top of the files this PR touches, so it reverts cleanly, and the UX issue it fixed is far less severe than silently dropping a user's typed input.
Assigned: @WojtekBoman (PR author), @Julesssss, @collectioneur, @huult (approving reviewers) from the highest-confidence causing PR only Labels: No changes. DeployBlockerCash is kept (an App PR caused it, so the App deploy stays blocked). DeployBlocker was not present, so nothing was removed.
📋 Detailed Analysis
Evidence
Staging-only, not reproducible on production, and v9.4.92-0 is the first build containing #101180 (merged 2026-09-22 17:55 UTC, position 60 in the chronological list on the deploy checklist).
Diffing production...staging shows the pages themselves (DynamicIOURequestStepDescription.tsx, DynamicIOURequestStepMerchant.tsx), the guard hook (useDiscardChangesConfirmation), useBeforeRemove, StepScreenWrapper and HeaderWithBackButton are all unchanged. The only changed file on the RHP back-button path is src/libs/Navigation/Navigation.ts, rewritten by this PR.
The RHP back button on these dynamic-route steps calls Navigation.goBack(backPath) with an explicit backTo (computed by useDynamicBackPath), which routes into goUp(). Plain RHP pages that call Navigation.goBack() with no backTo take the navigationRef.goBack() branch and are unaffected — which is exactly why this shows up on the migrated dynamic steps (Description, Merchant, and by the same mechanism Date/Category/etc.) rather than everywhere.
gh pr view 101180 --json files confirms the PR modifies src/libs/Navigation/Navigation.ts, src/libs/Navigation/helpers/linkTo/getMinimalAction.ts, src/libs/Navigation/helpers/linkTo/index.ts and adds src/libs/Navigation/helpers/hasDifferentSplitScope.ts. git log f04c5569b0e..staging on those paths is empty — no follow-up commits depend on it.
Note: this analysis is code, git-history and static-analysis only. Browser control was unavailable in this run, so the reproduction was not re-run interactively.
Root Cause
On the Description step the state is root: [TabNavigator, RightModalNavigator] with index: 1, and the back path is r/<reportID>, which resolves to the TabNavigator route at root index 0.
Before this PR, goUp() resolved the target once and dispatched exactly one action: StackActions.pop(1) targeted at the root stack.
After this PR, goUp() runs in two phases:
getPopsToNavigatorWithBackToRoute() walks from the root, finds the TabNavigator route at index 0 with distanceToPop = 1, and dispatches StackActions.pop(1) targeted at the root key.
It then re-reads the root state — the comment says "dispatch updates the state ref synchronously, and this must resolve against what the pops left" — and resolves the target again.
Phase 2 assumes phase 1 was applied. That holds on the happy path (after the pop, distanceToPop becomes 0 and the distanceToPop <= 0 early return fires). It does not hold when a screen guards the transition: useDiscardChangesConfirmation calls e.preventDefault() in its beforeRemove listener, so the root state is unchanged, phase 2 recomputes the identical distanceToPop = 1, and dispatches a secondStackActions.pop(1).
That second dispatch re-enters the same beforeRemove listener, and this time isDiscardModalOpen.current is already true, so it takes the branch that treats the event as a back-press over an already-open prompt and calls closeModal(). Because both showModal and closeModal are functional setModalStack updaters queued in the same React batch, the prompt is pushed and popped before it ever renders. Net result: navigation stays blocked (the user remains in the field) and no modal is ever painted — precisely the reported symptom, for Description, Merchant, and any other guarded step that passes an explicit backTo.
If a roll-forward is preferred over a revert, the minimal fix is to make phase 2 a no-op when phase 1 did not actually change anything — e.g. snapshot the root state before the pops and bail out (return didPopToNavigator) when getRootState() comes back identical, which means the action was prevented.
💡 Suggested AI code review rule
This bug looks like a recurring, mechanically detectable pattern, so it may be worth a coding-standards rule so the AI reviewer catches the next one. Proposed for Expensify/App:
Rule:CONSISTENCY-18 Do not assume a dispatched navigation action was applied
Condition: Flag code that dispatches a navigation action and then re-reads getRootState() / navigationRef.current.getState() to compute and dispatch a follow-up action. A screen's beforeRemove listener can call preventDefault(), leaving the state untouched, so the follow-up re-issues the same action and re-enters the guard. Snapshot the state before dispatching and bail out when it is unchanged, or derive every action from a single state read.
Why:goUp() dispatched the same root StackActions.pop(1) twice when the discard-changes guard blocked the first one; the second entry into beforeRemove closed the prompt it had just opened, so Back did nothing and the user got no discard prompt (#102010).
Search pattern:rg -U 'dispatch\([\s\S]{0,600}?getRootState\(\)' src/libs/Navigation — any function body containing a dispatch( call followed by a getRootState() read.
The full rule file, with the ❌/✅ code inline in Expensify/App's app-coding-standards format, would go in Expensify/App itself. If it's worth adding, a maintainer can open it there as a draft PR.
changed the title [-]Web - Expense - Back button does not trigger discard change modal on Description[/-][+][Due for payment 2026-10-01] Web - Expense - Back button does not trigger discard change modal on Description[/+]on Sep 24, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.92-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-10-01. 🎊
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]
Activity
applause-bot commentedon Sep 23, 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/60c4390379caee66e87ef2e4d42ed1f91a0fe475012fa98cc2fac78c0efb06ab
github-actions commentedon Sep 23, 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:
melvin-bot commentedon Sep 23, 2026
Triggered auto assignment to @blimpich (
DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.melvin-bot commentedon Sep 23, 2026
💬 A slack conversation has been started in #expensify-open-source
MelvinBot commentedon Sep 23, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #101180 - "Try it out button opens More features page of invited workspace as member" by @WojtekBoman (High confidence)
Related Issues: none found
Recommendation: REVERT
goUp()now dispatches the same back action twice, and the second dispatch immediately closes the discard prompt the first one opened. Nothing merged on top of the files this PR touches, so it reverts cleanly, and the UX issue it fixed is far less severe than silently dropping a user's typed input.Assigned: @WojtekBoman (PR author), @Julesssss, @collectioneur, @huult (approving reviewers) from the highest-confidence causing PR only
Labels: No changes.
DeployBlockerCashis kept (an App PR caused it, so the App deploy stays blocked).DeployBlockerwas not present, so nothing was removed.📋 Detailed Analysis
Evidence
v9.4.92-0is the first build containing #101180 (merged 2026-09-22 17:55 UTC, position 60 in the chronological list on the deploy checklist).production...stagingshows the pages themselves (DynamicIOURequestStepDescription.tsx,DynamicIOURequestStepMerchant.tsx), the guard hook (useDiscardChangesConfirmation),useBeforeRemove,StepScreenWrapperandHeaderWithBackButtonare all unchanged. The only changed file on the RHP back-button path issrc/libs/Navigation/Navigation.ts, rewritten by this PR.Navigation.goBack(backPath)with an explicitbackTo(computed byuseDynamicBackPath), which routes intogoUp(). Plain RHP pages that callNavigation.goBack()with nobackTotake thenavigationRef.goBack()branch and are unaffected — which is exactly why this shows up on the migrated dynamic steps (Description, Merchant, and by the same mechanism Date/Category/etc.) rather than everywhere.Verification
Affected files:
src/libs/Navigation/Navigation.ts#L539-L547— the new pre-pop phase added by this PRsrc/libs/Navigation/Navigation.ts#L604— the original pop, still reachedsrc/hooks/useDiscardChangesConfirmation/index.ts#L110-L121— where the second dispatch closes the promptsrc/pages/iou/request/step/DynamicIOURequestStepDescription.tsx#L191-L202— the guard registration (unchanged, correct)gh pr view 101180 --json filesconfirms the PR modifiessrc/libs/Navigation/Navigation.ts,src/libs/Navigation/helpers/linkTo/getMinimalAction.ts,src/libs/Navigation/helpers/linkTo/index.tsand addssrc/libs/Navigation/helpers/hasDifferentSplitScope.ts.git log f04c5569b0e..stagingon those paths is empty — no follow-up commits depend on it.Note: this analysis is code, git-history and static-analysis only. Browser control was unavailable in this run, so the reproduction was not re-run interactively.
Root Cause
On the Description step the state is
root: [TabNavigator, RightModalNavigator]withindex: 1, and the back path isr/<reportID>, which resolves to theTabNavigatorroute at root index 0.Before this PR,
goUp()resolved the target once and dispatched exactly one action:StackActions.pop(1)targeted at the root stack.After this PR,
goUp()runs in two phases:getPopsToNavigatorWithBackToRoute()walks from the root, finds theTabNavigatorroute at index 0 withdistanceToPop = 1, and dispatchesStackActions.pop(1)targeted at the root key.Phase 2 assumes phase 1 was applied. That holds on the happy path (after the pop,
distanceToPopbecomes 0 and thedistanceToPop <= 0early return fires). It does not hold when a screen guards the transition:useDiscardChangesConfirmationcallse.preventDefault()in itsbeforeRemovelistener, so the root state is unchanged, phase 2 recomputes the identicaldistanceToPop = 1, and dispatches a secondStackActions.pop(1).That second dispatch re-enters the same
beforeRemovelistener, and this timeisDiscardModalOpen.currentis alreadytrue, so it takes the branch that treats the event as a back-press over an already-open prompt and callscloseModal(). Because bothshowModalandcloseModalare functionalsetModalStackupdaters queued in the same React batch, the prompt is pushed and popped before it ever renders. Net result: navigation stays blocked (the user remains in the field) and no modal is ever painted — precisely the reported symptom, for Description, Merchant, and any other guarded step that passes an explicitbackTo.If a roll-forward is preferred over a revert, the minimal fix is to make phase 2 a no-op when phase 1 did not actually change anything — e.g. snapshot the root state before the pops and bail out (
return didPopToNavigator) whengetRootState()comes back identical, which means the action was prevented.💡 Suggested AI code review rule
This bug looks like a recurring, mechanically detectable pattern, so it may be worth a coding-standards rule so the AI reviewer catches the next one. Proposed for
Expensify/App:CONSISTENCY-18Do not assume a dispatched navigation action was appliedgetRootState()/navigationRef.current.getState()to compute and dispatch a follow-up action. A screen'sbeforeRemovelistener can callpreventDefault(), leaving the state untouched, so the follow-up re-issues the same action and re-enters the guard. Snapshot the state before dispatching and bail out when it is unchanged, or derive every action from a single state read.goUp()dispatched the same rootStackActions.pop(1)twice when the discard-changes guard blocked the first one; the second entry intobeforeRemoveclosed the prompt it had just opened, so Back did nothing and the user got no discard prompt (#102010).rg -U 'dispatch\([\s\S]{0,600}?getRootState\(\)' src/libs/Navigation— any function body containing adispatch(call followed by agetRootState()read.Navigation.ts#L539-L547plus the follow-up dispatch atNavigation.ts#L604Navigation.tsonproductionThe full rule file, with the ❌/✅ code inline in
Expensify/App'sapp-coding-standardsformat, would go inExpensify/Appitself. If it's worth adding, a maintainer can open it there as a draft PR.3 remaining items
WojtekBoman commentedon Sep 23, 2026
I prepared a draft PR including the adjustment to the original solution @huult @KJ21-ENG Could you take a look please?
blimpich commentedon Sep 23, 2026
Going to unassign my self since @Julesssss is already assigned and has context from this PR
Julesssss commentedon Sep 23, 2026
PR merged and being deployed
Julesssss commentedon Sep 23, 2026
PR Requested QA retest here. QA retest
m-natarajan commentedon Sep 23, 2026
Chrome / v9.4.92-5, Passed
bandicam.2026-09-23.20-31-44-758.mp4
[-]Web - Expense - Back button does not trigger discard change modal on Description[/-][+][Due for payment 2026-10-01] Web - Expense - Back button does not trigger discard change modal on Description[/+]melvin-bot commentedon Sep 24, 2026
@huult
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.92-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-10-01. 🎊
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]