Skip to content

Refactor Workspace menu data into a shared source - #97559

Merged
carlosmiceli merged 26 commits into
Expensify:mainfrom
nabi-ebrahimi:92752-shared-workspace-menu-source
Aug 20, 2026
Merged

carlosmiceli merged 26 commits into
Expensify:mainfrom
nabi-ebrahimi:92752-shared-workspace-menu-source

Conversation

@nabi-ebrahimi

@nabi-ebrahimi nabi-ebrahimi commented Jul 31, 2026 •

Copy link
Copy Markdown

Explanation of Change

Extracts the existing Workspace menu definitions from WorkspaceInitialPage into the shared getWorkspaceMenuItems helper.

The shared source owns the existing menu labels, icons, routes, ordering, permissions, feature gates, badges, RBRs, and highlight state. WorkspaceInitialPage continues to own hooks, policy loading, connection prefetching, rendering, and guarded navigation actions.

This is a behavior-preserving prerequisite for adding Workspace navigation suggestions in a follow-up PR. It does not add new Search Router suggestions or change the Workspace UI.

Fixed Issues

$ #92752
PROPOSAL: #92752 (comment)

Tests

Tests

Workspace menu remains unchanged

  1. Sign in and open any Workspace.
  2. Review the Workspace menu and its available subpages.
  3. Verify the same menu rows appear in the same order as before.

Expected: No Workspace menu item is added, removed, renamed, or reordered.

Workspace navigation remains unchanged

  1. Open several available Workspace subpages, such as Overview, Members, Rooms, Reports, and Workflows.
  2. Use the Workspace menu to move between them.

Expected: Every row opens its correct existing page, and the selected row remains highlighted.

Permissions and feature visibility remain unchanged

  1. Open a Workspace with optional features enabled.
  2. Verify its enabled feature pages appear.
  3. Repeat with a limited member or a Workspace where some features are disabled.

Expected: Users only see the same pages allowed by their permissions and enabled Workspace features.

Existing menu indicators remain unchanged

  1. Open a Workspace containing any badge, error indicator, or newly enabled feature highlight.
  2. Review the related menu rows.

Expected: Existing icons, badges, error indicators, and highlights appear as before.

Responsive layouts

  1. Open Workspace settings on narrow and wide layouts.
  2. Navigate through several Workspace subpages.

Expected: The menu, header, scrolling, focus, and navigation behave as before, with no visible UI changes.

  • Verify that no errors appear in the JS console

Offline tests

Same as Tests.

QA Steps

Same as Tests.

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Screen.Recording.2026-08-01.at.9.53.20.AM.mov
Android: mWeb Chrome
Screen_Recording_20260801_095012_Chrome.mp4
iOS: Native
Screen.Recording.2026-08-01.at.10.14.02.AM.mp4
iOS: mWeb Safari
Screen.Recording.2026-08-01.at.10.17.18.AM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-07-31.at.6.57.05.PM.mov
Screen.Recording.2026-08-01.at.8.54.53.AM.mov
Screen.Recording.2026-08-01.at.9.28.17.AM.mov
Screen.Recording.2026-08-01.at.9.29.20.AM.mov

@codecov

codecov Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/pages/workspace/getWorkspaceMenuItems.ts 100.00% <100.00%> (ø)
src/pages/workspace/WorkspaceInitialPage.tsx 0.00% <0.00%> (ø)
... and 18 files with indirect coverage changes

@melvin-bot
melvin-bot Bot requested a review from marufsharifi August 4, 2026 10:22
@melvin-bot

melvin-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

@marufsharifi Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and removed request for a team August 4, 2026 10:22

@JmillsExpensify JmillsExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No product review required.

@nabi-ebrahimi

Copy link
Copy Markdown
Author

@marufsharifi Addressed the above comment, ready for your review.

Comment thread tests/unit/getWorkspaceMenuItemsTest.ts Resolved
Comment thread tests/unit/getWorkspaceMenuItemsTest.ts Resolved
@nabi-ebrahimi

Copy link
Copy Markdown
Author

@marufsharifi Thanks for the thorough review. All valid comments have been addressed, including the regression and coverage gaps. Could you please take another look?

@marufsharifi

Copy link
Copy Markdown

@nabi-ebrahimi, thanks, checking again.

@nabi-ebrahimi

Copy link
Copy Markdown
Author

Resolved the conflict.

@nabi-ebrahimi

Copy link
Copy Markdown
Author

@marufsharifi Can you please review this when you got a chance, Thanks

Comment thread tests/unit/getWorkspaceMenuItemsTest.ts Resolved
@marufsharifi

Copy link
Copy Markdown

@MelvinBot Review.

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Review — this is a clean, faithful refactor. I traced all 21 menu rows and confirmed the extracted getWorkspaceMenuItems reproduces the original visibility conditions, ordering, icons, brick‑road indicators, badge, and highlight logic 1:1. No behavior change. All substantive CI is green (typecheck, ESLint, React Compiler, knip, jest). 👍

Behavior-preservation verification
  • Row conditions & order are identical to the old inline list — same gates (isGroupPolicy && shouldShowProtectedItems, per-feature canReadPolicyFeature/canReadMoreFeatures, policyFeatureStates[...]), same push order. The preserves the complete enabled Workspace menu order test locks the full 21-row order, routes, and screen names.
  • action → getRoute split is equivalent. Routes were already built lazily inside the old action closure, so deferring them behind getRoute() and re-wrapping with singleExecution(waitForNavigate(...)) in WorkspaceInitialPage preserves timing and the shared single-execution guard.
  • Pure substitutions, same values: expensifyIcons.X → injected icons.X; isConnectionInProgress(...) computed once and passed as connectionInProgress (was called twice, same result); beta flags passed in; Object.keys(...) as PolicyFeatureName[] → getObjectKeys(...) (identical keys/order).
  • Removed imports in WorkspaceInitialPage are confirmed unused by the green ESLint + knip checks.
  • Unit tests cover the meaningful edges: lazy route building, member-only rows, personal policy, highlight, employee-list error, Merge-HR info indicator, and rules-beta icon swap.

Optional (non-blocking): the icons injection + the 21-key WorkspaceMenuIconMap type add boilerplate that must be hand-maintained as icons change, and force the test to mock all 21. Since Expensicons are static assets, the helper could import * as Expensicons directly (with the rules-beta swap kept inside) and drop the param, the map type, and the mock. Purely a simplification call — fine to keep as-is if the injection is intentional for isolation.

The only red checks are the PR Reviewer Checklist / independent-approval process checks — nothing code-related; they'll clear once you complete the reviewer checklist Melvin pinged you about.

@nabi-ebrahimi

Copy link
Copy Markdown
Author

@marufsharifi resolved conflicts, thanks.

Comment thread tests/unit/getWorkspaceMenuItemsTest.ts Resolved
Comment thread tests/unit/getWorkspaceMenuItemsTest.ts Resolved
@marufsharifi

Copy link
Copy Markdown

@nabi-ebrahimi, could you please check the above comments. thanks.

@nabi-ebrahimi

Copy link
Copy Markdown
Author

@nabi-ebrahimi, could you please check the above comments. thanks.

@marufsharifi thanks for the review. All actionable comments have been addressed. Could you please review again?

@trjExpensify

Copy link
Copy Markdown
Contributor

Same here, @marufsharifi. Please complete your re-review today!

@marufsharifi

Copy link
Copy Markdown

I'am testing this, i will finish in a few hours. thanks.

@marufsharifi marufsharifi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested works perfect, but some minor suggestions.

Comment thread tests/unit/getWorkspaceMenuItemsTest.ts Resolved
@nabi-ebrahimi

Copy link
Copy Markdown
Author

@marufsharifi thanks for the detailed review. All actionable comments have been addressed. Could you please review again?

@marufsharifi marufsharifi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@melvin-bot
melvin-bot Bot requested a review from carlosmiceli August 20, 2026 11:17
@carlosmiceli
carlosmiceli merged commit e00b7f1 into Expensify:main Aug 20, 2026
41 of 44 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 carlosmiceli has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify OSBotify mentioned this pull request Aug 21, 2026
55 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/carlosmiceli in version: 9.4.58-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes required.

I reviewed the changes in this PR against the help site articles under App/docs/articles, and no documentation updates are needed — so I did not create a draft PR.

Why: This is a behavior-preserving internal refactor. It extracts the existing Workspace menu definitions from WorkspaceInitialPage into a shared getWorkspaceMenuItems helper, and adds a unit test for it. There are no user-facing changes.

Details

Files changed:

  • src/pages/workspace/WorkspaceInitialPage.tsx — menu-building logic moved out
  • src/pages/workspace/getWorkspaceMenuItems.ts — new helper holding the moved logic
  • tests/unit/getWorkspaceMenuItemsTest.ts — new unit test

The shared helper owns the same menu labels, icons, routes, ordering, permissions, feature gates, badges, RBRs, and highlight state that previously lived inline. Per the PR description, no Workspace menu item is added, removed, renamed, or reordered, and the Workspace UI is unchanged. Because nothing customer-facing (feature names, tab names, settings labels, buttons, or navigation) changed, none of the help articles need edits.

@nabi-ebrahimi — no linked help site PR was created since no docs changes are needed. If you believe a specific article should still be updated, reply with the article and what changed and I'll take another pass.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/Beamanator in version: 9.4.58-4 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants