Skip to content

Refactor Domain menu data into shared source - #97855

Merged
carlosmiceli merged 12 commits into
Expensify:mainfrom
nabi-ebrahimi:92752-shared-domain-menu-source
Aug 21, 2026
Merged

carlosmiceli merged 12 commits into
Expensify:mainfrom
nabi-ebrahimi:92752-shared-domain-menu-source

Conversation

@nabi-ebrahimi

@nabi-ebrahimi nabi-ebrahimi commented Aug 5, 2026 •

Copy link
Copy Markdown

Explanation of Change

This PR extracts the existing Domain menu definitions into a shared getDomainMenuItems builder and updates DomainInitialPage to consume it.

The menu order, labels, icons, routes, access rules, and error indicators remain unchanged. This is a behavior-preserving prerequisite for adding Domain navigation suggestions in a separate PR.

Fixed Issues

$ #92752
PROPOSAL: #92752 (comment)

Tests

Domain menu remains unchanged

Precondition: The user administers a domain.

  1. Open Workspaces.
  2. Open Domains.
  3. Select a domain.
  4. Verify the menu displays Members, Admins, Groups, and SAML in that order.
  5. Verify every row retains its expected label and icon.
  6. Open each row.

Expected: Every row opens its corresponding Domain page, and the menu looks and behaves as it did before this refactor.

  • 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-06.at.7.24.12.PM.mov
Android: mWeb Chrome
Recording_20260806_192841.mp4
iOS: Native
Screen.Recording.2026-08-06.at.7.48.40.PM.mov
iOS: mWeb Safari
Screen.Recording.2026-08-06.at.7.32.43.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-06.at.6.38.06.AM.mov

@codecov

codecov Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/pages/domain/getDomainMenuItems.ts 100.00% <100.00%> (ø)
src/pages/domain/DomainInitialPage.tsx 0.00% <0.00%> (ø)
... and 16 files with indirect coverage changes

@melvin-bot
melvin-bot Bot requested a review from marufsharifi August 7, 2026 06:48
@melvin-bot

melvin-bot Bot commented Aug 7, 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 flaviadefaria and removed request for a team August 7, 2026 06:48
@nabi-ebrahimi

Copy link
Copy Markdown
Author

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

Comment thread src/pages/domain/DomainInitialPage.tsx Resolved
Comment thread tests/unit/getDomainMenuItemsTest.ts Resolved
@marufsharifi

Copy link
Copy Markdown

@MelvinBot Review

@MelvinBot

Copy link
Copy Markdown
Contributor

Review — looks good ✅

This is a clean, behavior-preserving extraction. The menu order, labels, icons, routes, screenName, and error indicators are unchanged, and the new pure builder is well unit-tested. No blocking issues. All non-ignorable checks are green (only Check independent approval and checklist fail, which are the expected reviewer-checklist gates).

One thing to confirm, two optional nits:

1. Dropped highlighted / badgeText — verified safe, but intentional?
The old DomainMenuItem type had highlighted? and badgeText?, wired into the JSX as highlighted={!!item?.highlighted} and badgeText={item.badgeText}. Since no menu item ever set them, they were always false / undefined, and HighlightableMenuItem resolves highlighted ?? false — so removing them is behavior-identical. ✅ Just flagging that the new type drops these fields entirely, and the follow-up "Domain navigation suggestions" PR (the stated reason for this refactor) will likely need to re-add them. Fine to leave for that PR — just confirming the removal is deliberate.

Optional nits

2. Redundant icon re-mapping — DomainInitialPage.tsx:57-61 rebuilds the icon object field-by-field ({User: icons.User, UserShield: icons.UserShield, ...}). useMemoizedLazyExpensifyIcons(['UserLock', 'UserShield', 'User', 'Users']) already returns exactly Record<'UserLock' | 'UserShield' | 'User' | 'Users', IconAsset>, which matches DomainMenuIconMap, so you can just pass icons directly. Minor.

3. Test coverage — getDomainMenuItemsTest.ts covers order/routes/icons/screenNames and the three error indicators nicely. Optional: add a case asserting SAML never shows a brick road (it has no error selector), to lock that in against future edits.

Runtime check: I drove Workspaces → Domains on web with the test account, but it doesn't administer any domain (empty "Enhance your security with domains" state), so the admin menu itself couldn't be exercised at runtime. No errors or regressions in the reachable UI. The refactor's equivalence is well established by the static analysis above + the unit tests, so this is low risk.

Domains tab empty state

@nabi-ebrahimi

Copy link
Copy Markdown
Author

@marufsharifi thanks for the review. All comments have been addressed, and the focused checks and tests pass. Could you please take another look?

@quinthar quinthar removed the #migrate label Aug 13, 2026
@nabi-ebrahimi

Copy link
Copy Markdown
Author

@marufsharifi kindly bump, Thanks.

@marufsharifi

marufsharifi commented Aug 14, 2026 •

Copy link
Copy Markdown

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-08-20.at.12.05.07.PM.mov
Android: mWeb Chrome
Screen_Recording_20260814_152906_Chrome.mp4
iOS: HybridApp
Screen.Recording.2026-08-14.at.3.31.00.PM.mov
iOS: mWeb Safari
Screen.Recording.2026-08-14.at.3.34.09.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-08-14.at.3.21.12.PM.mov

@nabi-ebrahimi

Copy link
Copy Markdown
Author

@marufsharifi kindly bump, thanks.

@marufsharifi

Copy link
Copy Markdown

@nabi-ebrahimi, thanks, i am reviewing.

@trjExpensify

Copy link
Copy Markdown
Contributor

How are you getting on, do you think you'll complete the review today?

@marufsharifi

Copy link
Copy Markdown

@trjExpensify, yes, but Github is down.

@trjExpensify

Copy link
Copy Markdown
Contributor

Yeah, bad GH. Seems like we're back on track now!

@marufsharifi

Copy link
Copy Markdown

I will finish this in an hour. 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, it works perfect, but some minor suggestions.

Comment thread src/pages/domain/getDomainMenuItems.ts Resolved
Comment thread src/pages/domain/getDomainMenuItems.ts Resolved
Comment thread src/pages/domain/getDomainMenuItems.ts Resolved
Comment thread src/pages/domain/getDomainMenuItems.ts Resolved
Comment thread src/pages/domain/getDomainMenuItems.ts Resolved
Comment thread src/pages/domain/getDomainMenuItems.ts Resolved
Comment thread src/pages/domain/DomainInitialPage.tsx Resolved
Comment thread src/pages/domain/getDomainMenuItems.ts Resolved
Comment thread tests/unit/getDomainMenuItemsTest.ts Resolved
Comment thread src/pages/domain/DomainInitialPage.tsx Resolved
@nabi-ebrahimi

Copy link
Copy Markdown
Author

@marufsharifi thanks for the detailed review. All actionable comments have been addressed, and I replied to the optional items with the reasoning for keeping the current approach. Could you please review again?

@trjExpensify

Copy link
Copy Markdown
Contributor

... and another! @marufsharifi, please re-review it today.

@marufsharifi

Copy link
Copy Markdown

Thanks, i will finish this in afternoon.

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

Looks good, but a minor suggestion.

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

Copy link
Copy Markdown
Author

@marufsharifi thanks for the review. All actionable comments have been addressed. Please take another look.

@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:27
@nabi-ebrahimi

nabi-ebrahimi commented Aug 20, 2026 •

Copy link
Copy Markdown
Author

@carlosmiceli can you please also merge this one too if it looks good to you, cause domain navigation is also blocked by this one. Thanks.

@nabi-ebrahimi

Copy link
Copy Markdown
Author

@trjExpensify I think we are waiting for your review as Product here, Thanks!

@carlosmiceli
carlosmiceli merged commit affd1bd into Expensify:main Aug 21, 2026
37 of 40 checks passed
@carlosmiceli

Copy link
Copy Markdown
Contributor

No need, I just had to leave yesterday before CI checks completed.

@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 22, 2026
61 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

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

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

@MelvinBot

Copy link
Copy Markdown
Contributor

Help site review: no changes required ✅

I reviewed the changes in this PR and no updates are needed to Expensify's help site files under App/docs/articles, so I did not create a draft docs PR.

Why: This is a behavior-preserving code refactor. It extracts the existing Domain menu definitions into a shared getDomainMenuItems builder and updates DomainInitialPage to consume it. As stated in the PR description and confirmed by the diff, the menu order, labels, icons, routes, access rules, and error indicators all remain unchanged.

What I checked
  • All three changed files are internal code/tests — src/pages/domain/DomainInitialPage.tsx, the new src/pages/domain/getDomainMenuItems.ts, and the new tests/unit/getDomainMenuItemsTest.ts. None touch user-facing copy, feature availability, or workflows.
  • The refactor introduces no new user-facing feature, no new setting/tab/button, and no change to what an admin sees or does on the Domain pages (Members, Admins, Groups, SAML).
  • The existing Domain help articles (e.g. App/docs/articles/new-expensify/domains/Manage-Domain-Members.md, Domain-Admins.md, Create-and-Manage-Domain-Groups.md, Set-Up-SAML-SSO.md) already describe the current behavior, which this PR preserves — so they remain accurate.
  • Help site articles document user-facing product behavior, not internal code structure, so an internal builder refactor like this has no corresponding docs.

The PR itself notes this is a prerequisite for adding Domain navigation suggestions in a separate PR — that follow-up may introduce user-facing behavior worth documenting, but this one does not.

@nabi-ebrahimi, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR Ready for review

Note: no help site PR was created because this refactor has no user-facing changes to document. If you believe a docs update is still warranted (e.g. for the upcoming Domain navigation suggestions feature), let me know and I'll draft one.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/AndrewGable in version: 9.4.59-5 🚀

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.

7 participants