Skip to content

MenuItemWithTopDescription decomposition - simplest usages - #100191

Merged
roryabraham merged 28 commits into
Expensify:mainfrom
software-mansion-labs:war-in/menu-item-with-top-description-decomposition
Sep 9, 2026
Merged

roryabraham merged 28 commits into
Expensify:mainfrom
software-mansion-labs:war-in/menu-item-with-top-description-decomposition

Conversation

@war-in

@war-in war-in commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Phase 3 of the MenuItem decomposition:

  • Split the text leaves into Title, Description, FieldName, FieldNamePlaceholder and FieldValue, over two shared bases (BaseMenuItemPrimaryText, BaseMenuItemSupportingText).
  • Keyed the accessibility slots by line (top/bottom) instead of role, so the announced order matches the visual one for both field and navigation rows.
  • Replaced MenuItemEmptyField with a MenuItemField preset that renders both the filled (name + value) and empty (name only) shapes.
  • Migrated ~107 MenuItemWithTopDescription call sites across 55 screens to MenuItemField.
  • Added a Phase 3 section to the MenuItemComparison story, one card per prop shape.

Fixed Issues

$ #100312
PROPOSAL:

Tests

  1. Open Storybook (npm run storybook) and go to the MenuItem Comparison story.

  2. Scroll to the Phase 3 — MenuItemWithTopDescription section.

  3. Verify that for every card the legacy MenuItemWithTopDescription column, the composable column, and the preset column render identically — same font size, weight, line height, spacing, chevron placement, and truncation.

  4. Filled field rows: navigate to Settings > Profile > (a chat) > Notification preferences row, Workspace > Categories > (a category) settings, Workspace > Tags > (a tag) settings, Workspace > Members > (a member) details, and Workspace > Per diem > (a rate) details.

  5. Verify that each row shows the small grey field name on the top line and the full-contrast value below it, with a chevron when the row is pressable.

  6. Tap the rows and verify navigation still works, and that non-interactive rows (e.g. Travel > Trip details > Car type) show no chevron and do not respond to taps.

  7. Empty field rows: go to Settings > Preferences > Vacation delegate with no delegate set, and Workspace > Company cards > Assign card > Confirmation with an unfilled field.

  8. Verify that the field name renders at normal (not small) font size and takes over the row, with the chevron on the right.

  9. Turn on VoiceOver (iOS) / TalkBack (Android) and focus one filled row and one empty row.

  10. Verify that the row is announced as a single element reading the top line first then the bottom line (e.g. "Notification preferences, Daily"), and the empty row announces just the field name.

Offline tests

N/A — presentational refactor only; no API calls or Onyx writes were changed.

QA Steps

Same as tests (steps 4-10; the Storybook step is dev-only).

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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@codecov

codecov Bot commented Sep 3, 2026 •

Copy link
Copy Markdown

@war-in

war-in commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@MelvinBot review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Code review of the MenuItemWithTopDescription → MenuItemField migration.

The component work is solid: MenuItemField takes Omit<MenuItemRootProps, 'accessibilityLabel'> and destructures every key, so nothing is silently dropped, and collapsing interactive + shouldShowRightIcon into "chevron follows onPress" is correct at all 41/27 call sites I checked. One real bug, plus a few notes.

🔴 Empty-value guards dropped around interpolated translate() keys

ConfirmationBusiness.tsx:111 and :125 lost their guards:

-title={values[INCORPORATION_TYPE] ? translate(`businessInfoStep.incorporationType.${values[INCORPORATION_TYPE]}`) : ''}
+value={translate(`businessInfoStep.incorporationType.${values[BUSINESS_INFO_STEP_KEYS.INCORPORATION_TYPE]}` as TranslationPaths)}

values comes from getSubStepValues(...), so these can be ''. With an empty value the key becomes businessInfoStep.incorporationType. / allStates..stateName, which Localize.translate handles by throwing in dev and, on prod/staging, firing Log.alert and rendering the raw key path. The as TranslationPaths cast means typecheck can't catch it.

It also defeats the new empty-field shape this PR adds — value is a non-empty garbage string, so MenuItemField renders the filled shape instead of the placeholder. Restoring the ternary with undefined instead of '' gives you the placeholder for free:

value={values[BUSINESS_INFO_STEP_KEYS.INCORPORATION_TYPE] ? translate(`...${values[...]}` as TranslationPaths) : undefined}

Notes

  • helperText has no home in the preset. Three sites now hand-roll the same replacement — a wrapping <View> plus <FormHelpMessage isError={false} shouldShowRedDotIndicator={false} style={[styles.mt0, ...]}/> (ConfirmDelegatePage.tsx:93-99, DynamicXeroTravelBillingConfigurationPage.tsx:55-60). Three copies of an identical style array will drift. Worth either a helperText prop on MenuItemField or a shared wrapper before phase 4 adds more.
  • Chevron/pressability coupling is undocumented. Because the chevron follows onPress, shouldShowRightIcon !== interactive can't be expressed — EnablePayments/.../ConfirmationStep.tsx:57-71 had to drop to raw MenuItem.Root composition for it. The tradeoff looks right, but say so in the preset's JSDoc so the next migrator doesn't rediscover it.
  • Stale doc on MenuItemRoot. MenuItemRoot.tsx:34-38 still says the label is derived "from registered Title/Description children" — the slots are top/bottom now.
  • Minor edge: HotelTripDetails.tsx:68-72 guards on !!reservation.roomClass but passes value={reservation.roomClass.trim()}, so a whitespace-only roomClass renders the empty-field placeholder. Guard on the trimmed value.
  • Dropping rightLabel in CreateReportFieldsPage.tsx:245 is a no-op — legacy MenuItem only renders rightLabel when title is falsy (MenuItem.tsx:1191) and that row has a title. Flagging only so it's a deliberate removal, not an accident.

Housekeeping

  • typecheck and ESLint check are red, but both fail only on src/hooks/useTransactionInlineEdit.ts (Cannot find name 'originalUseOnyx'), which this PR doesn't touch — pre-existing on main. Merge main to clear them.
  • ### Fixed Issues is still $ / PROPOSAL: with nothing linked, and every Screenshots/Videos section is empty while all five platform checkboxes are checked.

I reviewed this statically and didn't run the app — the accessibility ordering change (slots keyed top/bottom instead of title/description) is the part worth a real VoiceOver/TalkBack pass, since nothing in CI covers it.


view run

@JakubKorytko JakubKorytko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, one dropped label and two small ones

Comment thread src/pages/workspace/reports/CreateReportFieldsPage.tsx Outdated
Comment thread src/pages/settings/Security/AddDelegate/ConfirmDelegatePage.tsx
Comment thread src/components/MenuItem/presets/MenuItemField.tsx
@war-in

war-in commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

@Pujan92 all yours 😄

@Pujan92

Pujan92 commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

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 any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • 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 and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-09-09.at.14.34.16.mov
Screen.Recording.2026-09-09.at.14.25.26.mov
Screen.Recording.2026-09-09.at.14.22.20.mov

@Pujan92

Pujan92 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

@war-in let's merge main and fix conflicts

Comment on lines +55 to +60
<MenuItem.Root onPress={!isBankAccountAdded ? handleModifyAccountNumbers : undefined}>
<MenuItem.Row>
<MenuItem.Content>
{!!bankName && <MenuItem.FieldName>{bankName}</MenuItem.FieldName>}
<MenuItem.FieldValue>{`${translate('bankAccount.accountEnding')} ${accountNumber.slice(-4)}`}</MenuItem.FieldValue>
</MenuItem.Content>

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.

can't we use MenuItemField here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

MenuItemField requires the title. Here, title can be undefined, so we would have to make the name optional only for this usage, which doesn't seem reasonable

@Pujan92

Pujan92 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Are we good to have 20px gap between MenuItemRow childrens which seems to not present in the legacy?

Screenshot 2026-09-09 at 14 52 03

@war-in

war-in commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Are we good to have 20px gap between MenuItemRow childrens which seems to not present in the legacy?

Yes! I discussed this with Shawn and he agreed that the icon should have some space around it

…osition

# Conflicts:
#	src/components/MenuItem/index.ts
#	src/components/MenuItem/leaves/content/base/MenuItemLabel.tsx
#	src/pages/DynamicReportParticipantDetailsPage.tsx
#	src/pages/domain/Groups/PreferredWorkspaceToggle.tsx
#	src/pages/workspace/reports/CreateReportFieldsPage.tsx
#	src/pages/workspace/reports/ReportFieldsValueSettingsPage.tsx
@war-in

war-in commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

@Pujan92 review addressed

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

LGTM!

@roryabraham
roryabraham merged commit 3607634 into Expensify:main Sep 9, 2026
36 of 39 checks passed
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify

OSBotify commented Sep 9, 2026

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 Sep 9, 2026
83 tasks done
@OSBotify

OSBotify commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/roryabraham in version: 9.4.75-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site changes required

I reviewed all 78 changed files. Nothing in docs/articles needs updating, so I did not create a draft docs PR.

Why: this is a presentational refactor of the MenuItem component tree. Every call-site change is a mechanical prop rename onto the new MenuItemField preset — description → name, title → value — reusing the same existing translation keys. No feature, flow, label, or setting name changed.

What I checked

No copy changed. Zero files under src/languages/ are touched, and zero files under docs/ are touched. Every name= / value= prop in the diff resolves to a translation key that was already rendering on that row before this PR (for example notificationPreferencesPage.label, workspace.categories.glCode, travel.trainDetails.seat, domain.groups.preferredWorkspace).

Representative call site — src/pages/ProfilePage.tsx:328: the Notification preferences row swaps MenuItemWithTopDescription for MenuItemField, keeping the same key, same onPress route, and same chevron.

The three behavioral notes in the PR body are all invisible to the help site:

  1. Splitting text leaves over BaseMenuItemPrimaryText / BaseMenuItemSupportingText — internal component structure. The PR's own Storybook test asserts the legacy and new columns render identically (same font size, weight, line height, spacing, chevron placement, truncation).
  2. Keying accessibility slots by line (top/bottom) instead of role — changes screen-reader announcement order only. docs/articles documents product features and workflows, not screen-reader output, so there is nothing there to correct.
  3. Replacing MenuItemEmptyField with a MenuItemField preset that renders both shapes — the empty-field row (for example Vacation delegate with none set) still shows the field name at normal size with a chevron, exactly as before.

Affected surfaces are all already documented accurately. The migrated screens include Notification preferences, workspace Categories / Tags / Members / Per diem / Company cards, Vacation delegate, and the accounting integration pages. Since the rendered text and navigation on each of those rows is unchanged, the existing articles still match the live UI.

@war-in, since this refactor introduces no user-facing change, there is no linked help site PR to review. If you disagree — for example if a row's label or behavior did shift in a way I missed — reply with @MelvinBot <details> and I'll draft the docs PR.

@IuliiaHerets

Copy link
Copy Markdown

Hey @war-in. Is it an internal PR?

cc @roryabraham @JakubKorytko @Pujan92

@war-in

war-in commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Hey @war-in. Is it an internal PR?

@IuliiaHerets I'm not sure if I understand, could you clarify?

@IuliiaHerets

Copy link
Copy Markdown

@war-in We can follow only steps 4–8. The other steps are out of our scope.

@war-in

war-in commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

@IuliiaHerets That's what I mentioned in the PR description 😄 But can't you test VoiceOver & TalkBack? I added it to the test steps to make sure accessibility works as expected

@IuliiaHerets

Copy link
Copy Markdown

@war-in VoiceOver & TalkBack is out of the scope of our work

@war-in

war-in commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

@IuliiaHerets oh, I didn't know that. So I think it's fine to just test 4-8

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀

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

Bundle Size Analysis (Sentry):

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.4.75-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 failure ❌
🍎 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