Skip to content

[Performance] Paginate the OpenPolicyRooms flow for large workspaces #97325

Closed

Description

@melvin-bot

Problem

On the workspace Rooms page, opening the page fires the OpenPolicyRoomsPage command with only a policyID and no pagination parameters. The backend returns every room (policyExpenseChat) for the workspace in a single response, and the frontend table renders the entire list with infinite scroll and no paging.

For very large workspaces (tens of thousands of members → tens of thousands of rooms), this means a single request tries to return all rooms at once. This has been observed taking ~47s to complete for an admin on a workspace with ~22k members, which contributes to long skeleton/loading states on that page.

Current behavior

  • WorkspaceRoomsPage requests all rooms on focus with no pagination:
  • openPolicyRoomsPage sends only {policyID}:
    • function openPolicyRoomsPage(policyID: string) {
      const params: OpenPolicyRoomsPageParams = {policyID};
      const finallyData: Array<OnyxUpdate<typeof ONYXKEYS.ARE_POLICY_ROOMS_LOADED>> = [
      {
      onyxMethod: Onyx.METHOD.MERGE,
      key: ONYXKEYS.ARE_POLICY_ROOMS_LOADED,
      value: {
      [policyID]: true,
      },
      },
      ];
      read(READ_COMMANDS.OPEN_POLICY_ROOMS_PAGE, params, {finallyData});
      }
  • The list/table renders the full result set with no server-side paging.

Impact

  • Slow initial load and long loading skeletons on the Rooms page for large workspaces.
  • Large single API response and heavy client-side list rendering.
  • Scales linearly with member count, so it gets worse as a workspace grows.

Proposed solution

Design and introduce pagination for the Rooms flow, end to end:

  • Add pagination parameters (page size / cursor or offset, and optionally a search term) to the OpenPolicyRoomsPage command and its backend implementation.
  • Return rooms in bounded pages instead of the full set.
  • Update the frontend (openPolicyRoomsPage action + WorkspaceRoomsPage/WorkspaceRoomsTable) to request pages on demand (infinite scroll / "load more") and to support server-side search so admins on huge workspaces can find a room without loading everything.

Open design questions to settle in the issue:

  • Page size and cursor vs. offset pagination.
  • Whether search/filter should be server-side for large workspaces.
  • How this interacts with the ongoing table-component refactor.

Context: reported while investigating slow loads for a large enterprise workspace; the OpenPolicyRooms response was the dominant cost (~47s) for an admin on a ~22k-member workspace.

Issue OwnerCurrent Issue Owner: @hoangzinh

Activity

  1. added
    Hot Pick
    on Jul 29, 2026
  2. self-assigned this
    on Jul 30, 2026
  3. removed
    Hot Pick
    on Jul 30, 2026
  4. hungvu193 commented on Jul 31, 2026

    @hungvu193
    Contributor

    on it 👀

  5. hungvu193 commented on Jul 31, 2026

    @hungvu193
    Contributor

    @mountiny Do we need to create a separate BE issue for this one? We might need to paginate + add query params to search the room name.

  6. mountiny commented on Jul 31, 2026

    @mountiny
    Contributor

    I think you can keep it as part of this issue, yeah I agree the search will need to be updated too

  7. added
    Reviewing
    Weekly
    and removed
    Daily
    on Aug 3, 2026
  8. hungvu193 commented on Aug 3, 2026

    @hungvu193
    Contributor

    All there PRs are ready for review, but we should wait for the first Auth PR to be deployed.

    https://github.com/Expensify/Auth/pull/23377 is ready for your review @mountiny

  9. self-assigned this
    on Aug 10, 2026
  10. 25 remaining items

  11. added
    Reviewing
    and removed
    External
    on Aug 29, 2026
  12. melvin-bot commented on Sep 7, 2026

    @melvin-bot
    Author

    @hoangzinh Huh... This is 4 days overdue. Who can take care of this?

  13. hoangzinh commented on Sep 8, 2026

    @hoangzinh
    Contributor

    Updates: we're still working through the PR #97665

  14. melvin-bot commented on Sep 15, 2026

    @melvin-bot
    Author

    @hoangzinh Whoops! This issue is 2 days overdue. Let's get this updated quick!

  15. melvin-bot commented on Sep 17, 2026

    @melvin-bot
    Author

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

  16. hoangzinh commented on Sep 18, 2026

    @hoangzinh
    Contributor

    The App PR will be merged soon #97665

  17. hungvu193 commented on Sep 23, 2026

    @hungvu193
    Contributor

    The automation has failed I guess. App PR hit prod 2 days ago.

  18. hoangzinh commented on Sep 23, 2026

    @hoangzinh
    Contributor

    @hungvu193, do we have any other App PRs coming up, or are we all set?

  19. hungvu193 commented on Sep 23, 2026

    @hungvu193
    Contributor

    We're all set here 😃

  20. hoangzinh commented on Sep 23, 2026

    @hoangzinh
    Contributor

    Should we close this issue then? I have a payment issue here #101777

  21. hungvu193 commented on Sep 23, 2026

    @hungvu193
    Contributor

    Sure.

  22. jayeshmangwani commented on Dec 2, 2026

    @jayeshmangwani
    Contributor

    Returning early when offline prevented openPolicyRoomsPage from being called. As a result, isLoaded remained undefined, causing the Rooms page to show a loader while offline #107079. We've fixed this here: #107303

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

Metadata

Metadata

Labels

DailyReviewingTask

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions