Skip to content

Accounting - Central pane shows Workspaces page when Accounting page is loading #84225

Closed

Description

@mitarachim

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.31-1
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/TR-7606/folder/13176902/41237402/1228588873
Email or phone of affected tester (no customers): jsodijosjdnonjsijdoisj@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 26.2 / Chrome
App Component: Workspace Settings

Action Performed:

  1. Go to staging.new.expensify.com
  2. Create a workspace.
  3. Go to workspace settings > More features.
  4. Enable Accounting.
  5. Quickly go to Accounting.

Expected Result:

Central pane will show loading screen.

Actual Result:

Central pane shows Workspaces page when Accounting page is loading.

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Image
Bug7094119_1772662782065.19.mp4

View all open jobs on GitHub

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    DeployBlockerIndicates it should block deploying the API
    on Mar 5, 2026
  2. melvin-bot commented on Mar 5, 2026

    @melvin-bot

    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.

  3. melvin-bot commented on Mar 5, 2026

    @melvin-bot

    Triggered auto assignment to @amyevans (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  4. melvin-bot commented on Mar 5, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on Mar 5, 2026

    @github-actions
    Contributor

    👋 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:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. MelvinBot commented on Mar 5, 2026

    @MelvinBot
    Contributor

    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, 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:

    newFeatureStates[key] =
        prevPendingFields?.[key] !== policy?.pendingFields?.[key] || isOffline || !policy?.pendingFields?.[key]
            ? isFeatureEnabled
            : currentFeatureStates[key];

    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:

    const canAccessRoute = activeRoute && (workspaceMenuItems.some((item) => item.screenName === activeRoute) || activeRoute === SCREENS.WORKSPACE.INITIAL);

    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)

    1. 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.

    2. 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.

  7. 2 remaining items

  8. amyevans commented on Mar 5, 2026

    @amyevans
    Contributor

    @mkhutornyi what'd you determine?

  9. amyevans commented on Mar 5, 2026

    @amyevans
    Contributor

    @MelvinBot this is a deploy blocker. Which PR(s) that recently deployed to staging are most likely to have introduced the regression?

  10. mkhutornyi commented on Mar 5, 2026

    @mkhutornyi
    Contributor

    I managed to find the offending PR. I'll wait to post until Melvin finds something (testing Melvin's ability) 😅

  11. MelvinBot commented on Mar 5, 2026

    @MelvinBot
    Contributor

    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.

    Files changed:

    • src/libs/Navigation/AppNavigator/createRootStackNavigator/useCustomRootStackNavigatorState/index.ts
    • src/libs/Navigation/AppNavigator/usePreloadFullScreenNavigators.ts

    2. #84135 — "perf: skip findLastAccessedReport scan..." — Lower suspicion

    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).

  12. mkhutornyi commented on Mar 5, 2026

    @mkhutornyi
    Contributor

    Genius 🧠
    I confirmed the regression came from #83887. Reverting fixes it.

  13. amyevans commented on Mar 5, 2026

    @amyevans
    Contributor

    Nice, thanks!

  14. mkhutornyi commented on Mar 5, 2026

    @mkhutornyi
    Contributor

    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!

  15. added
    ReviewingHas a PR in review
    and removed
    DeployBlockerIndicates it should block deploying the API
    on Mar 5, 2026
  16. amyevans commented on Mar 5, 2026

    @amyevans
    Contributor
  17. m-natarajan commented on Mar 5, 2026

    @m-natarajan

    Can’t reproduce, Chrome / v9.3.31-5

    Screen.Recording.2026-03-05.at.20.08.28.mp4
  18. amyevans commented on Mar 5, 2026

    @amyevans
    Contributor

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.EngineeringHourlyKSv2ReviewingHas a PR in review

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions