App icon indicating copy to clipboard operation
App copied to clipboard

[Due for payment 2026-12-02] [$175] Workspaces - Rooms page loads indefinitely when opened after creating a workspace offline

Open applause-bot[bot] opened this issue 2 weeks ago • 13 comments

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.40-0 Reproducible in staging?: Yes Reproducible in production?: Yes 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/84222789/folder/53676270/41237923/1982039009?sort=%2Bidentifier Email or phone of affected tester (no customers): n/a Issue reported by: Applause Internal Team Bug source: Regression TC Execution Device used: Mac 26.5.1 Safari, iPhone 13 iOS 26.6 App Component: Workspace Settings

Action Performed:

  1. Go to https://staging.new.expensify.com
  2. Navigate to Workspaces and go offline
  3. Click on the New workspace button to create a new workspace
  4. Click "Confirm" button
  5. Click the Rooms tab

Expected Result:

The Rooms page should load successfully

Actual Result:

Rooms page loads indefinitely when opened after creating a workspace offline.

Workaround:

Unknown

Platforms:

  • [ ] Android: App
  • [ ] Android: mWeb Chrome
  • [x] iOS: App
  • [ ] iOS: mWeb Safari
  • [ ] iOS: mWeb Chrome
  • [x] Windows: Chrome
  • [x] MacOS: Chrome Safari

Screenshots/Videos

https://github.com/user-attachments/assets/83164c8a-73f2-4e9b-882c-7c580af7a7af

View all open jobs on GitHub

Applause Internal Information Exported by: Julia Ponikarchuk Bug ID: 7316151

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @jayeshmangwani

applause-bot[bot] avatar Nov 17 '26 05:11 applause-bot[bot]

While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/bf0725520d60dd1d645d93b02d8dc52731d2c0e1afd6471ebcc49debf9c86004

applause-bot[bot] avatar Nov 17 '26 05:11 applause-bot[bot]

Triggered auto assignment to Contributor-plus team member for initial proposal review - @jayeshmangwani (External)

Job added to Upwork: https://www.upwork.com/jobs/~022122567490983281705

Proposal

What is the root cause of that problem?

Medium confidence — supported by code; offline reproduction remains unverified.

The Rooms table treats missing “loaded” metadata as an active load, even while offline. Creating a workspace initializes its rooms optimistically, but not this metadata. Opening Rooms offline skips the request that would mark it loaded, so the table indefinitely hides available rooms behind a loading skeleton.

Code evidence and alternatives checked

Missing optimistic reports were considered, but the room selector accepts those reports. The loading gate prevents them from rendering.

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

Make the table’s initial loading skeleton online-only. While offline, render locally available rooms—or the existing empty state when none are cached. Preserve the existing offline request guard and reconnection fetch.

Regression coverage should verify offline creation → Confirm → Rooms, an uncached workspace offline, unchanged online loading, and successful refresh after reconnection.

What alternative solutions did you explore? (Optional)

Initializing isLoaded during workspace creation would mask this case but leave other never-loaded workspaces affected offline. Changing only isLoading would not fix the skeleton’s actual condition.

Web verification — partial; reproduction blocked

🤖 Web test steps verification results: ⚠️ partial

Workspaces opens online on dev NewDot web. Offline setup was blocked because the permitted controls exposed no usable offline toggle; Rooms behavior remains unverified.

Online Workspaces page showing no existing workspaces
Step Status
1. Open Workspaces onlineWorkspaces and New workspace were visible.
Online Workspaces page showing no existing workspaces
✅
2. Go offlineBlocked: no usable offline control was available.
⚠️
3. Click New workspaceNot attempted without the required offline state.
⚠️
4. Confirm creation offlineBlocked by offline setup.
⚠️
5. Open Rooms/check loadingBlocked: no offline-created workspace was available.
⚠️

Next Steps for Contributor+ team:
To accept: @MelvinBot implement this proposal to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.


view run · no recording available

MelvinBot avatar Nov 17 '26 05:11 MelvinBot

Proposal

Please re-state the problem that we are trying to solve in this issue.

After creating a workspace while offline and tapping Confirm, opening the Rooms tab shows the loading skeleton forever, even though the rooms exist locally. The page never recovers until the device is back online.

What is the root cause of that problem?

The loading gate and the fetch gate disagree about offline. openPolicyRoomsPage (src/libs/actions/Policy/Room.ts:49-60) only sets isLoaded: true in finallyData, when the request completes — and WorkspaceRoomsPage.tsx:143-149 never issues that request while offline (if (!isFocused || isOffline) { return; }). Meanwhile WorkspaceRoomsTable/index.tsx:144-152 shows <Table.LoadingState /> whenever !roomsMetadata?.isLoaded, with no connectivity check at all. The optimistic room reports created with the workspace (src/libs/actions/Policy/Policy.ts:3207-3247) are in Onyx and accepted by the room selector, but the skeleton hides them indefinitely.

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

Make the table's initial loading skeleton online-only: read useNetwork() in WorkspaceRoomsTable (the same hook the page already uses) and, while offline, render the table from the locally cached rooms — or the existing empty state when none are cached — instead of the skeleton. Keep the page's offline fetch guard and the refetch-on-reconnect behaviour unchanged, so online loading and refresh-after-reconnect work exactly as today.

What alternative solutions did you explore? (Optional)

Seeding isLoaded during workspace creation would mask only the freshly-created-workspace case and leave every other never-loaded workspace stuck offline. Changing only isLoading would not fix the skeleton, whose condition is isLoaded.

How will you verify the fix?

Reproduce the issue steps: create a workspace offline, Confirm, open Rooms and confirm the rooms render; open an uncached workspace offline and confirm the empty state (not the skeleton); confirm online loading is unchanged; go back online and confirm the list refreshes. Add tests for offline creation → Confirm → Rooms, uncached workspace offline, and refresh after reconnection.

Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01c5c6bc0e7d162f7b

khizzcr7 avatar Nov 17 '26 06:11 khizzcr7

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

melvin-bot[bot] avatar Nov 17 '26 06:11 melvin-bot[bot]

Contributor details Your Expensify account email: [email protected]

Proposal

Please re-state the problem that we are trying to solve in this issue.

After creating a new workspace while offline and clicking "Confirm", navigating to the Rooms tab causes the Rooms page to show a loading skeleton (<Table.LoadingState />) indefinitely instead of displaying the created workspace rooms (or the empty state).

What is the root cause of that problem?

The root cause lies in an offline gate mismatch between data fetching and UI rendering:

  1. Offline Guard on Fetch (src/pages/workspace/rooms/WorkspaceRoomsPage.tsx:143–149): WorkspaceRoomsPage guards its fetch effect so that openPolicyRoomsPage is explicitly bypassed while offline:

    useEffect(() => {
        if (!isFocused || isOffline) {
            return;
        }
    
        openPolicyRoomsPage(policyID, pageNumber, sortBy, roomSort.order, searchValue);
    }, [isFocused, isOffline, pageNumber, policyID, roomSort.order, searchValue, sortBy]);
    
  2. Sole Writer of isLoaded (src/libs/actions/Policy/Room.ts:49–60): openPolicyRoomsPage is the only function that sets isLoaded: true in ONYXKEYS.POLICY_ROOMS_METADATA:

    const finallyData: Array<OnyxUpdate<typeof ONYXKEYS.POLICY_ROOMS_METADATA>> = [
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: ONYXKEYS.POLICY_ROOMS_METADATA,
            value: {
                [policyID]: {
                    isLoading: false,
                    isLoaded: true,
                },
            },
        },
    ];
    

    Because openPolicyRoomsPage is never triggered while offline, roomsMetadata?.isLoaded remains undefined.

  3. Unconditional Loading Gate (src/components/Tables/WorkspaceRoomsTable/index.tsx:146–153): WorkspaceRoomsTable intercepts rendering and displays <Table.LoadingState /> whenever !roomsMetadata?.isLoaded:

    if (!roomsMetadata?.isLoaded) {
        return (
            <>
                {headerComponent}
                <Table.LoadingState />
            </>
        );
    }
    

    Because the table does not check whether the client is offline, it assumes data is actively being fetched from the server and traps the user on the loading skeleton indefinitely, even though the optimistic room reports created with the workspace (such as #admins and #announce) are already cached in Onyx and available via policyReports (policyChatRoomsSelector).

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

  1. Make the initial loading skeleton online-only in src/components/Tables/WorkspaceRoomsTable/index.tsx: Import useNetwork and bypass the full-page loading skeleton when isOffline is true:

    // Import hook:
    import useNetwork from '@hooks/useNetwork';
    
    // Inside WorkspaceRoomsTable:
    const {isOffline} = useNetwork();
    

    Update the loading condition at line 146:

    if (!roomsMetadata?.isLoaded && !isOffline) {
        // The page header stays visible above the loading skeleton so the layout doesn't jump once the table renders.
        return (
            <>
                {headerComponent}
                <Table.LoadingState />
            </>
        );
    }
    
    • When offline, the component proceeds directly to render <Table data={rooms} ...>, which immediately displays the locally cached / optimistic rooms (or <Table.EmptyState> if no rooms are present).
    • Client-side search (isItemInSearch) and client-side sorting (compareItems) inside WorkspaceRoomsTable remain fully functional while offline.
    • When network connectivity is restored, the useEffect in WorkspaceRoomsPage.tsx automatically triggers openPolicyRoomsPage, which fetches the latest server state, updates roomsMetadata.isLoaded: true, and refreshes the list seamlessly.
  2. Automated Unit Tests: Add unit tests verifying that:

    • When roomsMetadata?.isLoaded is undefined and isOffline: true, the table renders local room rows instead of <Table.LoadingState />.
    • When roomsMetadata?.isLoaded is undefined and isOffline: false, <Table.LoadingState /> is rendered.
    • When transitioning isOffline from true to false, openPolicyRoomsPage is called.

What alternative solutions did you explore? (Optional)

  • Seeding isLoaded: true in buildPolicyData (Policy.ts) during workspace creation: Rejected because it only solves the case for a freshly created workspace, but leaves any existing workspace opened for the first time while offline stuck in the infinite loading state.
  • Passing isOffline as a prop from WorkspaceRoomsPage to WorkspaceRoomsTable: Viable, but calling useNetwork() directly inside WorkspaceRoomsTable follows existing table patterns (e.g. WorkspaceCompanyCardsTable:105) and keeps the component's public prop interface minimal.

gorky117-cell avatar Nov 17 '26 08:11 gorky117-cell

@MelvinBot implement

jayeshmangwani avatar Nov 18 '26 19:11 jayeshmangwani

🤖 Web test steps verification results: ⚠️ partial

Implemented in draft Show workspace rooms instead of endless loading while offline; four regression tests, lint, typecheck, formatting, compiler check, and Storybook passed. Dev web opened successfully, but offline verification was blocked by unavailable offline controls; the full Jest suite timed out.

Account Profile screen while searching for an in-app offline control
Step Status
1. Open dev NewDot webConfirmed a signed-in, onboarded session.
✅
2. Navigate to Workspaces and go offlineWorkspaces opened; no supported offline control was available.
Account Profile screen while searching for an in-app offline control
⚠️
3. Click New workspace offlineBlocked by offline setup.
⚠️
4. Click Confirm offlineBlocked by offline workspace creation.
⚠️
5. Verify Rooms displays without an indefinite skeletonOffline browser behavior remains unverified.
⚠️
6. Verify uncached Rooms shows an empty state offlineBlocked by offline setup.
⚠️
7. Verify reconnect refreshes RoomsCould not perform an offline-to-online transition.
⚠️

view run · no recording available

MelvinBot avatar Nov 18 '26 20:11 MelvinBot

Triggered auto assignment to @mountiny, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@jayeshmangwani

The solution for this issue has been :rocket: deployed to production :rocket: in version 9.5.53-3 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

  • https://github.com/Expensify/App/pull/107303

If no regressions arise, payment will be issued on 2026-12-02. :confetti_ball:

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]

melvin-bot[bot] avatar Nov 25 '26 15:11 melvin-bot[bot]

@jayeshmangwani

The solution for this issue has been :rocket: deployed to production :rocket: in version 9.5.53-3 and is now subject to a 7-day regression period :calendar:. Here is the list of pull requests that resolve this issue:

  • https://github.com/Expensify/App/pull/107303

If no regressions arise, payment will be issued on 2026-12-02. :confetti_ball:

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]

melvin-bot[bot] avatar Nov 25 '26 15:11 melvin-bot[bot]

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