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
Accounting - Central pane shows Workspaces page when Accounting page is loading #84225
👋 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.
Please re-state the problem that we are trying to solve in this issue.
When the user enables Accounting in workspace More Features and quickly navigates to the Accounting page, the central pane briefly shows the Workspaces list page instead of a loading screen. This happens on wide-screen web (MacOS Chrome).
What is the root cause of that problem?
The root cause is a race condition in WorkspaceInitialPage's feature state synchronization with the navigation state.
When the user enables Accounting, enablePolicyConnections fires an optimistic Onyx update that sets policy.areConnectionsEnabled = true and policy.pendingFields.areConnectionsEnabled = 'update' atomically (Policy.ts:4397-4443).
However, WorkspaceInitialPage manages sidebar menu visibility through a local featureStates useState (line 203) that is updated via a useEffect (lines 452-480). This effect intentionally defers feature state updates while pending fields exist to stay in sync with AccessOrNotFoundWrapper:
On the first render after the optimistic update, prevPendingFields differs from policy.pendingFields, so the state updates correctly. But on subsequent renders where prevPendingFields equals policy.pendingFields and the pending field is still set, the condition falls through and keeps the old value (connections disabled). This means the Accounting sidebar menu item may not appear immediately.
The canAccessRoute check at line 502 validates whether the current central pane screen is in the sidebar menu:
When the user quickly navigates to Accounting and featureStates hasn't yet reflected the change, the Accounting screen is NOT in workspaceMenuItems, making canAccessRoute false. On a fresh mount of WorkspaceInitialPage (which can happen when the navigation creates a new WorkspaceSplitNavigator), wasRendered.current is false, and Navigation.closeRHPFlow() is called (lines 504-516). While closeRHPFlow itself targets the RHP modal, the cascading effect of the navigation state mismatch — combined with the WORKSPACES_LIST route that is always injected underneath the WORKSPACE_SPLIT_NAVIGATOR in the root stack (getAdaptedStateFromPath.ts:278-285) — causes the Workspaces list page to show through.
Meanwhile, PolicyAccountingPage is wrapped by withPolicyConnections (withPolicyConnections.tsx:29-61) which would correctly show a FullScreenLoadingIndicator while fetching connections data, but the navigation dismissal happens before this component gets a chance to render.
What changes do you think we should make in order to solve the problem?
The fix should ensure that the canAccessRoute check in WorkspaceInitialPage accounts for features that are pending (their toggle was just changed and the server hasn't confirmed yet). Specifically:
In WorkspaceInitialPage.tsx, the canAccessRoute check at line 502 should also consider whether the activeRoute corresponds to a feature that has a pending field. If a feature is pending, the route should be considered accessible even if the sidebar menu item hasn't appeared yet. This prevents the navigation from being disrupted during the brief window between the optimistic update and the featureStates synchronization.
Alternatively, the featureStates update logic could be adjusted to synchronously reflect optimistic feature enablement (not just on pending field transitions), ensuring the sidebar menu item appears immediately when a feature is toggled on.
What alternative solutions did you explore? (Optional)
Moving the loading indicator higher in the component tree: Having the WorkspaceSplitNavigator show a loading indicator when the central pane screen's feature is pending. This would be more invasive and affect all workspace screens.
Removing the deferred featureStates logic entirely: Using policyFeatureStates directly instead of the local featureStates useState. However, this deferred logic exists for a reason — to prevent flicker during workspace creation when features toggle multiple times. Removing it could reintroduce that issue.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.
I cross-referenced every PR in the deploy checklist against the files involved in this bug (navigation state management, workspace feature gating, split navigator routing). Here are the most likely culprits, ranked by suspicion:
1. #83887 — "Prevent LHN from remounting after navigating away from Inbox" — Highest suspicion
This PR changes the core logic in useCustomRootStackNavigatorState that determines which full-screen navigators remain mounted in the root stack. The old logic only kept a non-full-screen predecessor before the last full-screen navigator; the new logic always keeps at least one additional route (lastSplitIndex - 1). This means WORKSPACES_LIST — which is always injected underneath WORKSPACE_SPLIT_NAVIGATOR in the root stack — is now kept mounted where it previously would have been removed.
This directly interacts with the race condition described in my earlier analysis: when featureStates in WorkspaceInitialPage haven't caught up to the Accounting toggle yet, canAccessRoute evaluates to false and closeRHPFlow() fires. With more routes now in the root stack due to this PR, the navigation fallback behavior changes — potentially landing the user on WORKSPACES_LIST instead of staying within the WorkspaceSplitNavigator.
The PR also modifies usePreloadFullScreenNavigators.ts to skip preloading navigators already in the routes stack, which changes how WorkspaceSplitNavigator gets initialized depending on stack state.
Changes ReportsSplitNavigator initialization logic. Since this navigator lives in the root stack alongside WorkspaceSplitNavigator, changes to its initialization timing could indirectly affect navigation state resolution. Risk is lower since it only affects report navigation, not workspace navigation.
3. #84041 — "perf: Move ESC RHP handling to its own component" — Low suspicion
Moves ESC key handling from AuthScreens into a separate component, changing the re-render cascade of the root navigator. Unlikely to be the direct cause but changes rendering timing.
Recommendation: Start by reverting or testing without #83887. The change to root stack state slicing is the strongest match for the symptom (showing WORKSPACES_LIST during a race condition in workspace feature toggling).
Activity
melvin-bot commentedon Mar 5, 2026
Triggered auto assignment to @trjExpensify (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.melvin-bot commentedon Mar 5, 2026
Triggered auto assignment to @amyevans (
DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.melvin-bot commentedon Mar 5, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Mar 5, 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 Mar 5, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When the user enables Accounting in workspace More Features and quickly navigates to the Accounting page, the central pane briefly shows the Workspaces list page instead of a loading screen. This happens on wide-screen web (MacOS Chrome).
What is the root cause of that problem?
The root cause is a race condition in
WorkspaceInitialPage's feature state synchronization with the navigation state.When the user enables Accounting,
enablePolicyConnectionsfires an optimistic Onyx update that setspolicy.areConnectionsEnabled = trueandpolicy.pendingFields.areConnectionsEnabled = 'update'atomically (Policy.ts:4397-4443).However,
WorkspaceInitialPagemanages sidebar menu visibility through a localfeatureStatesuseState (line 203) that is updated via auseEffect(lines 452-480). This effect intentionally defers feature state updates while pending fields exist to stay in sync withAccessOrNotFoundWrapper:On the first render after the optimistic update,
prevPendingFieldsdiffers frompolicy.pendingFields, so the state updates correctly. But on subsequent renders whereprevPendingFieldsequalspolicy.pendingFieldsand the pending field is still set, the condition falls through and keeps the old value (connections disabled). This means the Accounting sidebar menu item may not appear immediately.The
canAccessRoutecheck at line 502 validates whether the current central pane screen is in the sidebar menu:When the user quickly navigates to Accounting and
featureStateshasn't yet reflected the change, the Accounting screen is NOT inworkspaceMenuItems, makingcanAccessRoutefalse. On a fresh mount ofWorkspaceInitialPage(which can happen when the navigation creates a newWorkspaceSplitNavigator),wasRendered.currentisfalse, andNavigation.closeRHPFlow()is called (lines 504-516). WhilecloseRHPFlowitself targets the RHP modal, the cascading effect of the navigation state mismatch — combined with theWORKSPACES_LISTroute that is always injected underneath theWORKSPACE_SPLIT_NAVIGATORin the root stack (getAdaptedStateFromPath.ts:278-285) — causes the Workspaces list page to show through.Meanwhile,
PolicyAccountingPageis wrapped bywithPolicyConnections(withPolicyConnections.tsx:29-61) which would correctly show aFullScreenLoadingIndicatorwhile fetching connections data, but the navigation dismissal happens before this component gets a chance to render.What changes do you think we should make in order to solve the problem?
The fix should ensure that the
canAccessRoutecheck inWorkspaceInitialPageaccounts for features that are pending (their toggle was just changed and the server hasn't confirmed yet). Specifically:In
WorkspaceInitialPage.tsx, thecanAccessRoutecheck at line 502 should also consider whether theactiveRoutecorresponds to a feature that has a pending field. If a feature is pending, the route should be considered accessible even if the sidebar menu item hasn't appeared yet. This prevents the navigation from being disrupted during the brief window between the optimistic update and thefeatureStatessynchronization.Alternatively, the
featureStatesupdate logic could be adjusted to synchronously reflect optimistic feature enablement (not just on pending field transitions), ensuring the sidebar menu item appears immediately when a feature is toggled on.What alternative solutions did you explore? (Optional)
Moving the loading indicator higher in the component tree: Having the
WorkspaceSplitNavigatorshow a loading indicator when the central pane screen's feature is pending. This would be more invasive and affect all workspace screens.Removing the deferred featureStates logic entirely: Using
policyFeatureStatesdirectly instead of the localfeatureStatesuseState. However, this deferred logic exists for a reason — to prevent flicker during workspace creation when features toggle multiple times. Removing it could reintroduce that issue.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR, or@MelvinBot <your feedback>to refine this analysis.2 remaining items
amyevans commentedon Mar 5, 2026
@mkhutornyi what'd you determine?
amyevans commentedon Mar 5, 2026
@MelvinBot this is a deploy blocker. Which PR(s) that recently deployed to staging are most likely to have introduced the regression?
mkhutornyi commentedon Mar 5, 2026
I managed to find the offending PR. I'll wait to post until Melvin finds something (testing Melvin's ability) 😅
MelvinBot commentedon Mar 5, 2026
I cross-referenced every PR in the deploy checklist against the files involved in this bug (navigation state management, workspace feature gating, split navigator routing). Here are the most likely culprits, ranked by suspicion:
1. #83887 — "Prevent LHN from remounting after navigating away from Inbox" — Highest suspicion
This PR changes the core logic in
useCustomRootStackNavigatorStatethat determines which full-screen navigators remain mounted in the root stack. The old logic only kept a non-full-screen predecessor before the last full-screen navigator; the new logic always keeps at least one additional route (lastSplitIndex - 1). This meansWORKSPACES_LIST— which is always injected underneathWORKSPACE_SPLIT_NAVIGATORin the root stack — is now kept mounted where it previously would have been removed.This directly interacts with the race condition described in my earlier analysis: when
featureStatesinWorkspaceInitialPagehaven't caught up to the Accounting toggle yet,canAccessRouteevaluates tofalseandcloseRHPFlow()fires. With more routes now in the root stack due to this PR, the navigation fallback behavior changes — potentially landing the user onWORKSPACES_LISTinstead of staying within theWorkspaceSplitNavigator.The PR also modifies
usePreloadFullScreenNavigators.tsto skip preloading navigators already in the routes stack, which changes howWorkspaceSplitNavigatorgets initialized depending on stack state.Files changed:
src/libs/Navigation/AppNavigator/createRootStackNavigator/useCustomRootStackNavigatorState/index.tssrc/libs/Navigation/AppNavigator/usePreloadFullScreenNavigators.ts2. #84135 — "perf: skip findLastAccessedReport scan..." — Lower suspicion
Changes
ReportsSplitNavigatorinitialization logic. Since this navigator lives in the root stack alongsideWorkspaceSplitNavigator, changes to its initialization timing could indirectly affect navigation state resolution. Risk is lower since it only affects report navigation, not workspace navigation.3. #84041 — "perf: Move ESC RHP handling to its own component" — Low suspicion
Moves ESC key handling from
AuthScreensinto a separate component, changing the re-render cascade of the root navigator. Unlikely to be the direct cause but changes rendering timing.Recommendation: Start by reverting or testing without #83887. The change to root stack state slicing is the strongest match for the symptom (showing
WORKSPACES_LISTduring a race condition in workspace feature toggling).mkhutornyi commentedon Mar 5, 2026
Genius 🧠
I confirmed the regression came from #83887. Reverting fixes it.
amyevans commentedon Mar 5, 2026
Nice, thanks!
mkhutornyi commentedon Mar 5, 2026
Maybe we can patch without reverting if this is only 1 blocker from that PR.
cc: @TMisiukiewicz
EDIT: another blocker #84025 (comment) so let's revert!
amyevans commentedon Mar 5, 2026
Requested retest: https://expensify.slack.com/archives/C09V78U42D8/p1772733850182499
m-natarajan commentedon Mar 5, 2026
Can’t reproduce, Chrome / v9.3.31-5
Screen.Recording.2026-03-05.at.20.08.28.mp4
amyevans commentedon Mar 5, 2026
Thanks!