[$250] Members - Browser back buttton does not return to workspace page after viewing chat history
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.33-0 Reproducible in staging?: Yes Reproducible in production?: N/A - new feature, doesn't exist in prod If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/App/pull/105050 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.5 / Chrome App Component: Workspace Settings
Action Performed:
- Go to staging.new.expensify.com
- Go to workspace settings > Members.
- Invite a member.
- Click on the invited user.
- Click See chat history.
- Click browser back button.
Expected Result:
App will return to workspace members page.
Actual Result:
App remains on Spend page, although URL changes to workspace members URL.
Workaround:
Unknown
Platforms:
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [x] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/7237b69e-7dab-4c1a-a271-501f049504ff
Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7306616
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022118740289886855682
- Upwork Job ID: 2118740289886855682
- Last Price Increase: 2026-11-25
Issue Owner
Current Issue Owner: @MannA-001
While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/fbc2f83de425943f2ed66bd098021e6265c1c051394cde7cf21a7359848b5edf
You have been assigned to this deploy blocker because you recently merged this PR: https://github.com/Expensify/App/pull/105050
@NikkiWines @sobitneupane you have been assigned to this deploy blocker because you reviewed the offending PR: https://github.com/Expensify/App/pull/105050
π¬ A slack conversation has been started in #expensify-open-source
:wave: 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.
- Find someone who can quickly fix the issue.
- Fix the issue yourself.
@MelvinBot Could you please post a proposal for this issue?
@MelvinBot Could you please post a proposal for this issue?
@NikkiWines Since this is a minor issue, I don't think we need to revert the PR.
I agree, but let's push up a fix of it asap π
@MelvinBot Could you please post a proposal for this issue?
Proposal
Preliminary β medium confidence. Source review supports this mechanism, but the saved/current navigation states at the failing browser Back have not been captured. This is not yet a runtime-verified fix.
What is the root cause of that problem?
The suspected cause is that browser Back mistakes removal of leading history padding for an ordinary last-entry pop. It dispatches GO_BACK to the root navigator instead of restoring the saved Members state. With only one root route, that action cannot change the screen, explaining how the URL could return to Members while Spend/Search remains visible.
Supporting code
- ProfileUtils.ts:32β38 opens chat history using reveal-before-dismiss.
- GetStateForActionHandlers.ts:634β697 changes the tab within the existing root route. History handling:154β164 prepends padding.
- The upstream pop check:131β155 compares history lengths. Our patch:142β161 excludes trailing custom entries, but not leading padding.
- Saved history
[Tab]versus current[padding, Tab]can consequently qualify incorrectly. StackRouter.tsx:697β711 cannot handle Back at index zero.
These example histories are inferred from the code, not captured from the reported failure. If runtime states differ, this diagnosis needs revision.
What changes do you think we should make in order to solve the problem?
Tighten the ordinary-pop predicate in the existing React Navigation dependency patch:
- Require saved history to equal current history with its final entry removed, rather than merely checking that it has one fewer entry.
- Compare custom strings by value and route entries by key, with explicit type checks. Do not compare entire route objects or parameters, so legitimate pops retain live parameter updates.
- Keep the trailing-custom-entry guard and targeted
GO_BACK. Otherwise, use the existing saved-state restoration fallback.
For [padding, Tab] β [Tab], the stricter check fails and selects restoration of Members instead of an unhandled root Back.
Required validation before acceptance: capture the failing saved/current histories and dispatched action; then test the actual web linking handler for this case, ordinary Back preserving live parameters, custom history entries, and repeated Back/Forward. Verify both URL and visible Members state, including padding bookkeeping after restoration. No code changes or runtime validation of this proposal have been performed.
What alternative solutions did you explore? (Optional)
- Disabling optimized Back whenever padding exists would unnecessarily reset valid navigation.
- Removing the action target could pop an unrelated nested screen.
- Changing only member-page navigation would avoid rather than correct the suspected shared-history issue. This proposal does not require reverting the feature PR.
Next Steps for Contributor+ team:
To accept: Confirm the runtime state and regression behavior above before requesting implementation.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvinβs proposal.
Current assignee @sobitneupane is eligible for the External assigner, not assigning anyone new.
Job added to Upwork: https://www.upwork.com/jobs/~022118740289886855682
π¨ Edited by proposal-police: This proposal was edited at 2026-11-18 11:20:32 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
On web, clicking See chat history from workspace Member details navigates to Search. Pressing browser Back changes the URL to the workspace members page, but the app visually remains on Search.
What is the root cause of that problem?
PR #105050 introduced ProfileUtils.navigateToChatHistory to share chat history navigation between ProfilePage and WorkspaceMemberDetailsPage.
ProfileUtils.navigateToChatHistory calls Navigation.revealRouteBeforeDismissingModal. That method serves modal submission flows. It dispatches the REPLACE_FULLSCREEN_UNDER_RHP action.
In workspace settings, the fullscreen route under the RHP is WORKSPACE_NAVIGATOR. REPLACE_FULLSCREEN_UNDER_RHP replaces WORKSPACE_NAVIGATOR with SEARCH_FULLSCREEN_NAVIGATOR. It then dismisses the RHP. This completely removes the workspace members screen from the root navigation state.
When the user clicks browser Back, the browser URL returns to the workspace members URL. The linking handler receives the pop event and dispatches GO_BACK to the root navigator. Because SEARCH_FULLSCREEN_NAVIGATOR sits at root index zero with no preceding screen, GO_BACK cannot pop. The app stays visually frozen on Search.
What changes do you think we should make in order to solve the problem?
In src/libs/ProfileUtils.ts, dismiss the RHP modal first and navigate to Search in afterTransition (the standard pattern used in SearchNLFilterPage.tsx):
--- a/src/libs/ProfileUtils.ts
+++ b/src/libs/ProfileUtils.ts
@@ -35,7 +35,8 @@ function navigateToChatHistory(accountID: number) {
type: CONST.SEARCH.DATA_TYPES.CHAT,
from: [String(accountID)],
});
- Navigation.revealRouteBeforeDismissingModal(ROUTES.SEARCH_ROOT.getRoute({query, rawQuery: query}));
+ const route = ROUTES.SEARCH_ROOT.getRoute({query, rawQuery: query});
+ Navigation.dismissModal({afterTransition: () => Navigation.navigate(route)});
}
Dismissing the RHP modal before navigating prevents linkTo from pushing Search above the RHP stack. When the user clicks browser Back, exactly one click returns directly to the Workspace Members screen with the URL and UI in sync.
I verified this fix on this branch with a regression test in WorkspaceMemberDetailsPageTest.tsx.
Results demonstrating the fix (Before / After videos)
Before (App remains on Search after browser Back):
https://github.com/user-attachments/assets/6cfdd332-0c30-4cb8-b430-9ad68e02aa3f
After (Browser Back cleanly returns to Workspace Members):
https://github.com/user-attachments/assets/48ce0a14-7239-4a74-ad06-a522373ec86f
What alternative solutions did you explore? (Optional)
- Patching React Navigation
useLinkingin@react-navigation/nativeto skip root history padding. This adds upstream maintenance overhead to our patch file for a flow that should not be a reveal in the first place. - Plain
Navigation.navigate: When an RHP modal is open,linkTopushesTAB_NAVIGATORabove the RHP. Browser Back then re-opens Member Details instead of returning directly to Members.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01cfe51584d8033bdc
β Contributor details stored successfully. Thank you for contributing to Expensify!
β 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.
When a user opens Workspaces > [Workspace] > Members, clicks on a member to open the Member Details RHP modal, clicks Member details > View chat history (which navigates to the Reports / Search fullscreen page), and then clicks the browser Back button, the URL updates to the workspace members route (/workspaces/<policyID>/members), but the screen stays stuck on the Reports (Search) page instead of returning to the Workspace Members page.
What is the root cause of that problem?
In src/libs/ProfileUtils.ts (lines 33β39, added in PR #105050), navigateToChatHistory(accountID: number) navigates to the search page using Navigation.revealRouteBeforeDismissingModal(ROUTES.SEARCH_ROOT.getRoute({query, rawQuery: query})).
In src/libs/Navigation/Navigation.ts (lines 527β545), revealRouteBeforeDismissingModal dispatches REPLACE_FULLSCREEN_UNDER_RHP followed by dismissModal(). Inside the custom router (src/libs/Navigation/AppNavigator/createRootStackNavigator/RootStackRouter.ts), REPLACE_FULLSCREEN_UNDER_RHP replaces the underlying fullscreen route (WORKSPACE_NAVIGATOR) in the navigation state with SEARCH_FULLSCREEN_NAVIGATOR rather than pushing SEARCH_FULLSCREEN_NAVIGATOR on top of it, and does not sync browser history entries for a stack push. Consequently, when the user presses the browser Back button, the browser pops history back to /workspaces/<policyID>/members, or pops the modal entry, while the active fullscreen navigator in React Navigation state remains SEARCH_FULLSCREEN_NAVIGATOR.
What changes do you think we should make in order to solve the problem?
In src/libs/ProfileUtils.ts inside navigateToChatHistory(accountID: number):
- Replace
Navigation.revealRouteBeforeDismissingModal(ROUTES.SEARCH_ROOT.getRoute({query, rawQuery: query}))withNavigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query, rawQuery: query}))(orNavigation.dismissModal()followed byNavigation.isNavigationReady().then(() => Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query, rawQuery: query})))). - This pushes
SEARCH_FULLSCREEN_NAVIGATORonto the root stack while preservingWORKSPACE_NAVIGATORunderneath in the navigation history stack, so pressing the browser Back button cleanly popsSEARCH_FULLSCREEN_NAVIGATORand renders the Workspace Members page (WORKSPACE_NAVIGATOR).
What alternative solutions did you explore? (Optional)
We also explored modifying REPLACE_FULLSCREEN_UNDER_RHP in RootStackRouter.ts to push instead of replace, but revealRouteBeforeDismissingModal is intentionally designed for flows where the underlying fullscreen route should be replaced (such as closing an onboarding or confirmation flow). For navigateToChatHistory, standard Navigation.navigate after dismissing the modal is the right semantic because the user is navigating forward from Workspace Members to Search and expects Back to return to Workspace Members.
π£ @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>
Proposal
Please re-state the problem that we are trying to solve in this issue.
On Web and Desktop, when a user opens Workspaces > [Workspace] > Members, clicks on a workspace member to open WorkspaceMemberDetailsPage in the RHP, clicks See chat history (or View agent history), and then presses the browser Back button, the browser URL returns to /workspaces/:policyID/members (or the member details URL) while the UI stays stuck on the Search / Spend tab instead of returning to the Workspace Members page. The same broken browser Back behavior also occurs when clicking See chat history from a user's ProfilePage opened over Inbox.
What is the root cause of that problem?
-
Forward user navigation (
navigateToChatHistory) misusesNavigation.revealRouteBeforeDismissingModal: Insrc/libs/ProfileUtils.ts:33-39(extracted in PR#105050and called from bothsrc/pages/workspace/members/WorkspaceMemberDetailsPage.tsx:651andsrc/pages/ProfilePage.tsx:327),navigateToChatHistorynavigates to Search usingNavigation.revealRouteBeforeDismissingModal:function navigateToChatHistory(accountID: number) { const query = buildQueryStringFromFilterFormValues({ type: CONST.SEARCH.DATA_TYPES.CHAT, from: [String(accountID)], }); Navigation.revealRouteBeforeDismissingModal(ROUTES.SEARCH_ROOT.getRoute({query, rawQuery: query})); }revealRouteBeforeDismissingModal(src/libs/Navigation/Navigation.ts:1215-1284) is designed for one-way modal completion/submission flows (such as expense creation or workspace confirmation) where the modal's browser history entry should be replaced in-place (historyDelta === 0) rather than pushing a forward history entry. -
Exact mechanism why Browser Back gets stuck on Search (two-frame reveal padding +
isPoppingLastEntry/GO_BACK):- Before clicking "See chat history":
- Browser history entry
0(/workspaces/:policyID/members):rootState.routes = [TabNavigator(WORKSPACE_NAVIGATOR)],rootState.history = [{type: 'route', key: 'TabNavigator-1'}](length = 1). - Browser history entry
1(/workspaces/:policyID/members/:accountID):rootState.routes = [TabNavigator(WORKSPACE_NAVIGATOR), RightModalNavigator],rootState.history = [{type: 'route', key: 'TabNavigator-1'}, {type: 'route', key: 'RightModalNavigator-1'}](length = 2).
- Browser history entry
- Frame 1 (
REPLACE_FULLSCREEN_UNDER_RHP): Insrc/libs/Navigation/AppNavigator/createRootStackNavigator/GetStateForActionHandlers.ts:636-698,handleReplaceFullscreenUnderRHPswitches the active tab inside the existingTabNavigator-1route fromWORKSPACE_NAVIGATORtoSEARCH_FULLSCREEN_NAVIGATOR(index: 2), whilegetFrozenHistoryStateForReplaceFullscreenUnderRHPfreezesrootState.historyat length2and snapshotspendingReveal = {rhpKey, routesLengthAtCapture: 2, historyLengthAtCapture: 2}. - Frame 2 (
DISMISS_MODAL): WhenRightModalNavigatoris popped,getRevealDismissStateseeslengthDelta = 2 - 1 = 1and prepends'CUSTOM_HISTORY_ENTRY_REVEAL_PADDING'viabuildPaddedHistory:
BecauserootState.routes = [TabNavigator-1 (focused on SEARCH_FULLSCREEN_NAVIGATOR)] rootState.history = ['CUSTOM_HISTORY_ENTRY_REVEAL_PADDING', {type: 'route', key: 'TabNavigator-1'}] // length = 2getHistoryLength(focusedState) - getHistoryLength(previousFocusedState) === 2 - 2 === 0,useLinkingcallshistory.replaceon browser entry1(/search?q=type%3Achat...). - When the user presses Browser Back (
entry 1 -> entry 0): Inpatches/react-navigation/@react-navigation+native+7.4.1+001+initial.patch:143-162(useLinking.jspopstatehandler, updated in PR#104842):
Here:const [currentFocused, recordFocused] = findMatchingState(currentState, record.state); const isPoppingCustomHistoryEntry = typeof currentFocused?.history?.at(-1) === 'string'; if (previousIndex - index === 1 && currentFocused && recordFocused && !isPoppingCustomHistoryEntry && isPoppingLastEntry(currentFocused, recordFocused)) { dispatch({...CommonActions.goBack(), target: currentFocused.key}, ...); }currentFocusedis the root stack (history = ['CUSTOM_HISTORY_ENTRY_REVEAL_PADDING', {key: 'TabNavigator-1'}],length = 2) andrecordFocusedis the saved root stack at/workspaces/:policyID/members(history = [{key: 'TabNavigator-1'}],length = 1).- Because
'CUSTOM_HISTORY_ENTRY_REVEAL_PADDING'is prepended at index0(buildPaddedHistory),currentFocused.history.at(-1)is{type: 'route', key: 'TabNavigator-1'}(an object, not a string), soisPoppingCustomHistoryEntryevaluates tofalse! - Even worse, upstream React Navigation's
isPoppingLastEntry(currentFocused, recordFocused)checkscurrentHistory.length - recordHistory.length === 1(2 - 1 === 1) and compares the prefixcurrentHistory.slice(0, -1)(['CUSTOM_HISTORY_ENTRY_REVEAL_PADDING']) againstrecordHistory([{type: 'route', key: 'TabNavigator-1'}]) usingisRecordEqual, which only checksa.type === b.type && a.key === b.key(undefined === undefinedfor a string vs{type: 'route'}isfalse, or when both have padding,true), or dispatches{...CommonActions.goBack(), target: currentFocused.key}to the root stack. Because the root stack only hasroutes.length === 1(index: 0),StackRoutercannotGO_BACKat index 0, so the navigation state remains stuck onSEARCH_FULLSCREEN_NAVIGATORwhile the browser URL sits on/workspaces/:policyID/members!
- Before clicking "See chat history":
What changes do you think we should make in order to solve the problem?
-
Use
Navigation.navigateinnavigateToChatHistory(src/libs/ProfileUtils.ts:33-39): Clicking See chat history / View agent history fromWorkspaceMemberDetailsPageorProfilePageis a standard forward navigation, not a one-way modal form submission. ReplaceNavigation.revealRouteBeforeDismissingModalwithNavigation.navigate:/** Opens a chat search filtered to the messages sent by the given account */ function navigateToChatHistory(accountID: number) { const query = buildQueryStringFromFilterFormValues({ type: CONST.SEARCH.DATA_TYPES.CHAT, from: [String(accountID)], }); Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query, rawQuery: query})); }When
Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute(...))runs whileRIGHT_MODAL_NAVIGATORis on top of the root stack,linkTo(src/libs/Navigation/helpers/linkTo/index.ts:241-244) seescurrentTopRoute?.name !== NAVIGATORS.TAB_NAVIGATORandaction.payload.name === NAVIGATORS.TAB_NAVIGATOR, converting the action toPUSH. That pushes the SearchTAB_NAVIGATORcleanly onto the stack without mutating the underlyingWORKSPACE_NAVIGATORtab or injectingCUSTOM_HISTORY_ENTRY_REVEAL_PADDING, so pressing Browser Back returns directly to the previous screen (WorkspaceMemberDetailsPage->WorkspaceMembersPage). -
Also harden
isPoppingCustomHistoryEntryinpatches/react-navigation/@react-navigation+native+7.4.1+001+initial.patch(Defense-in-Depth for all genuinerevealRouteBeforeDismissingModalflows): Inpatches/react-navigation/@react-navigation+native+7.4.1+001+initial.patch:149-150,isPoppingCustomHistoryEntryonly checkstypeof currentFocused?.history?.at(-1) === 'string'(trailing modal sentinels), completely missing leadingCUSTOM_HISTORY_ENTRY_REVEAL_PADDINGentries whencurrentFocused.routes.length === recordFocused.routes.length(such as cross-tabrevealRouteBeforeDismissingModalwherehandleReplaceFullscreenUnderRHPswitches tabs inside the existingTAB_NAVIGATORwithout adding a root route). We should also check whether the history length difference comes from leading reveal-padding entries (currentFocused?.history?.at(0) === 'CUSTOM_HISTORY_ENTRY_REVEAL_PADDING'whencurrentFocused?.routes?.length === recordFocused?.routes?.length), souseLinkingfalls back toresetRoot(record.state)instead of dispatching a no-opGO_BACKto a 1-route root stack. -
Update existing unit test in
tests/ui/ProfilePageTest.tsx:709-714and add test coverage intests/ui/WorkspaceMemberDetailsPageTest.tsx:- In
tests/ui/ProfilePageTest.tsx, update line 709 to assertexpect(Navigation.navigate).toHaveBeenCalledWith(...). - In
tests/ui/WorkspaceMemberDetailsPageTest.tsx, add a test verifying that pressingmember-chat-history-menu-itemcallsNavigation.navigatewithROUTES.SEARCH_ROOT.getRoute({query, rawQuery: query}).
- In
What alternative solutions did you explore? (Optional)
- Passing
{forceReplace: true}or dismissing the modal before navigating: Dismissing the modal first and then navigating would either require two back presses or lose the RHP entry when the user expects Back from Search to return to the Workspace/Profile flow. UsingNavigation.navigatematches how other forward links from RHP details pages work across the app vialinkTo(src/libs/Navigation/helpers/linkTo/index.ts:241-244).
Proposal
What is the root cause of that problem?
In src/libs/ProfileUtils.ts (lines 34β40):
function navigateToChatHistory(accountID: number) {
const query = buildQueryStringFromFilterFormValues({
type: CONST.SEARCH.DATA_TYPES.CHAT,
from: [String(accountID)],
});
Navigation.revealRouteBeforeDismissingModal(ROUTES.SEARCH_ROOT.getRoute({query, rawQuery: query}));
}
When a user clicks "See chat history" inside WorkspaceMemberDetailsPage, navigateToChatHistory calls Navigation.revealRouteBeforeDismissingModal.
revealRouteBeforeDismissingModal is designed for flows where the modal's entry route should be completely replaced by the target route before closing the modal stack. In this context, it strips the underlying workspace members route (/settings/workspaces/:policyID/members) from the history stack and replaces it with ROUTES.SEARCH_ROOT.
Consequently, on Web, the workspace members page is discarded from the browser history entry. When the user clicks the browser back button from the Search results page, browser history does not have the workspace members page to return to, taking the user back to Home or an earlier unrelated page.
What changes do you think we should make in order to solve the problem?
- In
src/libs/ProfileUtils.ts, updatenavigateToChatHistoryto navigate normally without replacing the underlying route:- Call
Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query, rawQuery: query}))directly (or dismiss the modal while preserving the previous history stack entry so the workspace route stays in history).
- Call
- Alternatively, if navigating from workspace settings, allow passing an optional
backToor handle dismissal viaNavigation.dismissModal()followed byNavigation.navigate(), ensuring the workspace route remains intact in the browser history stack.
What alternative solutions did you explore? (Optional)
Setting explicit backTo: ROUTES.WORKSPACE_MEMBERS.getRoute(policyID) query parameter on SEARCH_ROOT. However, avoiding revealRouteBeforeDismissingModal in favor of standard stack navigation is much cleaner and fixes the back behavior universally across Profile and Workspace member views.
Contributor Details
Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0179cdc82689f205c7