Skip to content

[Due for payment 2026-05-22] [$250] The Workspaces tab does not restore the last workspace after refreshing. #89220

Closed

Description

@m-natarajan

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.64-21
Reproducible in staging?: Y
Reproducible in production?: N
If this was caught during regression testing, add the test name, ID and link from BrowserStack:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @dmkt9
Slack conversation (hyperlinked to channel name): #Open source

Action Performed:

  1. Open the application on desktop web.
  2. Navigate to Workspaces > [Workspace name] > Categories.
  3. Navigate to Home.
  4. Refresh the application.
  5. Navigate to Workspaces.

Expected Result:

The Categories view should remain displayed.

Actual Result:

The workspace list is displayed.

Workaround:

Unknown

Platforms:

Select the officially supported platforms where the issue was reproduced:

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

Screenshots/Videos

test.mp4
Recording.2778.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022049935326201562311
  • Upwork Job ID: 2049935326201562311
  • Last Price Increase: 2026-04-30

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 29, 2026
  2. github-actions commented on Apr 29, 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.
  3. melvin-bot commented on Apr 29, 2026

    @melvin-bot

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

  4. melvin-bot commented on Apr 29, 2026

    @melvin-bot

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

  5. MelvinBot commented on Apr 29, 2026

    @MelvinBot
    Contributor

    Proposal

    What is the root cause of that problem?

    After a page refresh, the session storage fallback in useRestoreWorkspacesTabOnNavigate.ts:58-60 searches for WORKSPACE_NAVIGATOR at the root level of the state tree returned by getStateFromPath. But getStateFromPath returns a state rooted at TAB_NAVIGATOR (per the linking config hierarchy), with WORKSPACE_NAVIGATOR nested inside it. So the findLast call never finds WORKSPACE_NAVIGATOR and returns undefined, causing the function to fall through to the workspaces list.

    The flow after refresh:

    1. sessionStorage correctly holds /workspaces/{policyID}/categories (saved by NavigationRoot.tsx:82-83)
    2. lastVisitedPath (Onyx) was overwritten to / when the user navigated to Home, so on refresh the app restores to Home — no workspace state in the live navigation tree
    3. The hook correctly falls through to the session storage path at line 58
    4. getWorkspacesTabStateFromSessionStorage() calls getStateFromPath(path) which returns {routes: [{name: TAB_NAVIGATOR, state: {routes: [{name: WORKSPACE_NAVIGATOR, ...}]}}]}
    5. .routes?.findLast(r => r.name === WORKSPACE_NAVIGATOR) searches root routes and finds only TAB_NAVIGATOR — returns undefined
    6. navigateToWorkspacesPage receives no lastWorkspacesTabNavigatorRoute and falls through to navigateToWorkspacesPage.ts:67: Navigation.navigate(ROUTES.WORKSPACES_LIST.route)

    The existing test mocks getWorkspacesTabStateFromSessionStorage to return WORKSPACE_NAVIGATOR at the root level, which doesn't match the real getStateFromPath output — masking this bug.

    What changes do you think we should make in order to solve the problem?

    In useRestoreWorkspacesTabOnNavigate.ts:58-60, drill into TAB_NAVIGATOR before searching for WORKSPACE_NAVIGATOR:

    // Current (broken):
    getWorkspacesTabStateFromSessionStorage()
        ?.routes?.findLast((route) => route.name === NAVIGATORS.WORKSPACE_NAVIGATOR)
        ?.state?.routes?.findLast(...)
    
    // Fixed:
    getWorkspacesTabStateFromSessionStorage()
        ?.routes?.findLast((route) => route.name === NAVIGATORS.TAB_NAVIGATOR)
        ?.state?.routes?.findLast((route) => route.name === NAVIGATORS.WORKSPACE_NAVIGATOR)
        ?.state?.routes?.findLast(...)
    

    Update the test mock at line 285-304 to return the real getStateFromPath shape (with TAB_NAVIGATOR wrapping WORKSPACE_NAVIGATOR).

    What alternative solutions did you explore? (Optional)

    An alternative would be to change getWorkspacesTabStateFromSessionStorage() to return only the workspace-relevant portion of the state tree (unwrap TAB_NAVIGATOR before returning). This would keep the hook code simpler but would require changes to the utility function and any other callers.


    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.

  6. arosiclair commented on Apr 30, 2026

    @arosiclair
    Contributor

    This is not so bad. Let's demote

  7. 35 remaining items

  8. melvin-bot commented on May 20, 2026

    @melvin-bot

    @sobitneupane Eep! 4 days overdue now. Issues have feelings too...

  9. melvin-bot commented on May 21, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  10. melvin-bot commented on May 22, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2049935326201562311/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  11. mallenexpensify commented on May 23, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @sobitneupane due $250 via NewDot

    @sobitneupane plz complete the BZ checklist and tag me in a post once you have.

  12. sobitneupane commented on May 25, 2026

    @sobitneupane
    Contributor

    BugZero Checklist:

    Regression Test Proposal

    Test:

    1. Open the web app.
    2. Navigate to Workspaces > [Workspace name] > Categories.
    3. Go to the Home page.
    4. Refresh the application.
    5. Navigate back to Workspaces.
    6. Verify that you are navigated to the Categories page opened in step 2.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-f757-a03b-00b9-204ca9180254
  13. sobitneupane commented on May 25, 2026

    @sobitneupane
    Contributor

    @mallenexpensify

    • checklist
  14. JmillsExpensify commented on Jul 28, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @sobitneupane

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions