Skip to content

refactor: migrate direct Button usages to composed Button (PR1 — workspace + settings) - #95046

Merged
mountiny merged 28 commits into
Expensify:mainfrom
software-mansion-labs:jmgraa/button-migration
Jul 17, 2026
Merged

mountiny merged 28 commits into
Expensify:mainfrom
software-mansion-labs:jmgraa/button-migration

Conversation

@jmgraa

@jmgraa jmgraa commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

This is the first batch (PR1 of 9) of an ongoing effort to migrate every direct <Button> usage (import Button from '@components/Button') over to the new composed ButtonComposed, so the old Button component can eventually be deprecated. This batch covers 39 files / 43 button instances — all of them the simplest shape in the migration: text-only, plain (no icon), in the workspace + settings areas.

I want to be upfront about the nature of this PR so it's easy to review: the change is almost entirely mechanical. Each swap follows a fixed set of prop-mapping rules — for example success/danger collapse into variant, small/large collapse into size, text="" moves into a <Button.Text> child, and pressOnEnter becomes a <Button.KeyboardShortcut> child. No business logic, callbacks, disabled/loading conditions, or navigation targets were changed; every prop is either renamed 1:1, mapped to its documented equivalent, or passed straight through unchanged. In short, these buttons should look and behave exactly as they did before.

On the videos: because the change is this repetitive and low-risk, I did not record a clip for all 21 screens. Recording every one would mostly be showing the same "text renders, correct color/size, press works" check over and over. Instead I've attached a few representative clips that exercise the parts of the mapping that carry the most regression risk — the variant colors (success/danger/default), the size mapping, disabled/loading states, and the Enter-key shortcut (<Button.KeyboardShortcut>).

Fixed Issues

$ #95169
PROPOSAL: #83762 (comment)

Tests

For every migrated button, verify that behaviour is unchanged from before the migration:

  1. Label renders correctly and is not clipped or truncated.
  2. Variant/color is correct — success = green, danger = red, default = grey.
  3. Size is correct — SMALL vs LARGE height/padding matches the previous look.
  4. Disabled state — the button greys out and is non-interactive when its precondition isn't met (dirty check, required field, offline).
  5. Loading state — the spinner replaces the label and the button is non-interactive while a request is in flight (isLoading).
  6. Press action — tapping fires the same documented action as before (navigates / submits / opens modal / external link).
  7. Enter-key shortcut (where applicable) — pressing Enter on web fires the same action (<Button.KeyboardShortcut>).

Offline tests

Same as test

QA Steps

Same as tests

  • 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 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 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 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 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

MacOS: Chrome / Safari (11 recordings)
  • src/pages/settings/Profile/Avatar/EditUserAvatarContent.tsx
  • src/pages/settings/Profile/Contacts/ContactMethodsPage.tsx
s1.mov
  • src/pages/settings/Security/TwoFactorAuth/DynamicTwoFactorAuthPage.tsx
  • src/pages/settings/Security/TwoFactorAuth/DynamicVerifyPage.tsx
s2.mov
  • src/pages/settings/Security/TwoFactorAuth/DisablePage.tsx
  • src/pages/settings/Security/TwoFactorAuth/DisabledPage.tsx
s3.mov
  • src/pages/settings/Security/DeviceManagementPage.tsx
s5.mov
  • src/pages/settings/Subscription/SubscriptionPlan/index.tsx
  • src/pages/settings/Subscription/SubscriptionPlan/SaveWithExpensifyButton/index.tsx
  • src/pages/workspace/downgrade/DowngradeIntro.tsx
  • src/pages/workspace/downgrade/PayAndDowngradePage.tsx
  • src/pages/workspace/upgrade/UpgradeIntro.tsx
  • src/pages/workspace/upgrade/GenericFeaturesView.tsx
s6.mov
  • src/pages/settings/Wallet/ImportTransactionsPage.tsx
s9.mov
  • src/pages/workspace/upgrade/UpgradeIntro.tsx
w1.mov
  • src/pages/workspace/tags/ImportMultiLevelTagsSettingsPage.tsx
w3.mov
  • src/pages/workspace/tags/ImportMultiLevelTagsSettingsPage.tsx
w4.mov
  • src/pages/workspace/travel/WorkspaceTravelInvoicingSection.tsx
w5.mov
  • src/pages/workspace/hr/HRApprovalModePageBase.tsx
  • src/pages/workspace/hr/merge/MergeHRGroupsPage.tsx
w6.mov
Android: Native (2 recordings)
  • src/pages/settings/Security/TwoFactorAuth/DynamicTwoFactorAuthPage.tsx
  • src/pages/settings/Security/TwoFactorAuth/DynamicVerifyPage.tsx
android1.mov
  • src/pages/workspace/tags/ImportMultiLevelTagsSettingsPage.tsx
android2.mov
iOS: Native (3 recordings)
  • src/pages/settings/Subscription/SubscriptionPlan/index.tsx
  • src/pages/settings/Subscription/SubscriptionPlan/SaveWithExpensifyButton/index.tsx
  • src/pages/workspace/downgrade/DowngradeIntro.tsx
  • src/pages/workspace/downgrade/PayAndDowngradePage.tsx
  • src/pages/workspace/upgrade/UpgradeIntro.tsx
  • src/pages/workspace/upgrade/GenericFeaturesView.tsx
ios1.mov
  • src/pages/workspace/tags/ImportMultiLevelTagsSettingsPage.tsx
ios2.mov
  • src/pages/workspace/hr/HRApprovalModePageBase.tsx
  • src/pages/workspace/hr/merge/MergeHRGroupsPage.tsx
ios3.mov

@codecov

codecov Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

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

I've looked through a couple of files and it looks good, 2 notes:

  1. I've already implemented the seatbelt in a separate PR, so it'll be just a matter of merging, good job though
  2. The same PR will change how a couple of props are being passed to the Button.KeyboardShortcut and removes the pressOnEnter since it is redundant - it could require conflict resolution and will simplify migration, so the extraction of the onPress functions will not be needed anymore

Beside that one export change, LGTM! 👀

Comment thread src/components/ButtonComposed/index.tsx Resolved
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@jmgraa
jmgraa force-pushed the jmgraa/button-migration branch from 6bce5b0 to 990b589 Compare July 6, 2026 11:34
@jmgraa
jmgraa force-pushed the jmgraa/button-migration branch from 990b589 to 74367bb Compare July 6, 2026 11:56
@jmgraa
jmgraa marked this pull request as ready for review July 7, 2026 08:51
@jmgraa
jmgraa requested review from a team as code owners July 7, 2026 08:51
@melvin-bot
melvin-bot Bot requested review from ZhenjaHorbach and joekaufmanexpensify and removed request for a team July 7, 2026 08:51
@melvin-bot

melvin-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

@ZhenjaHorbach 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 a team and removed request for a team July 7, 2026 08:51
@jmgraa

jmgraa commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@ZhenjaHorbach all updated, ready for merge

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

Will complete checklist today or tomorrow!

@ZhenjaHorbach

ZhenjaHorbach commented Jul 16, 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 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
2026-07-17.10.48.29.mov
2026-07-17.10.48.49.mov
2026-07-17.10.49.19.mov
2026-07-17.10.54.08.mov
2026-07-17.10.55.01.mov
2026-07-17.10.55.18.mov
Android: mWeb Chrome
2026-07-17.10.39.40.mov
2026-07-17.10.40.10.mov
2026-07-17.10.40.34.mov
2026-07-17.10.41.19.mov
2026-07-17.10.41.55.mov
2026-07-17.10.42.57.mov
iOS: HybridApp
2026-07-17.10.48.29.mov
2026-07-17.10.48.49.mov
2026-07-17.10.49.19.mov
2026-07-17.10.54.08.mov
2026-07-17.10.55.01.mov
2026-07-17.10.55.18.mov
iOS: mWeb Safari
2026-07-17.10.39.40.mov
2026-07-17.10.40.10.mov
2026-07-17.10.40.34.mov
2026-07-17.10.41.19.mov
2026-07-17.10.41.55.mov
2026-07-17.10.42.57.mov
MacOS: Chrome / Safari
2026-07-17.10.26.00.mov
2026-07-17.10.26.54.mov
2026-07-17.10.28.47.mov
2026-07-17.10.30.23.mov
2026-07-17.10.31.20.mov

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@jmgraa
Can you please update the branch to the latest version of main?

@mountiny

Copy link
Copy Markdown
Contributor

@ZhenjaHorbach waiting for your confirmation

@melvin-bot
melvin-bot Bot requested a review from mountiny July 17, 2026 08:59
@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

LGTM!

@mountiny
mountiny merged commit 5d8ddff into Expensify:main Jul 17, 2026
33 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.41-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Help site review: no docs changes required.

I reviewed the changes in this PR against the help site content under App/docs/articles.

This is a purely mechanical component migration — swapping direct @components/Button usages for the composed @components/ButtonComposed. Every change is a prop remap (success/danger → variant, small/large → size, text="…" → <Button.Text> child, pressOnEnter → <Button.KeyboardShortcut> child). No feature names, tab names, settings labels, button copy, or workflows changed:

  • All button labels continue to use the same existing translate() keys (e.g. common.done, contacts.newContactMethod, twoFactorAuth.disable) — no new or altered user-facing copy was introduced.
  • No navigation targets, business logic, or user-facing behavior were changed, per the PR's own summary ("these buttons should look and behave exactly as they did before").

Since the help site documents product features and workflows — not internal component structure — there is nothing to update. No draft PR was created.

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

@IuliiaHerets

Copy link
Copy Markdown

Hi @jmgraa. Could you please share more detailed testing steps for this PR?

cc @mountiny @ZhenjaHorbach @Guccio163 @dariusz-biela

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.4.41-4 🚀

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

Bundle Size Analysis (Sentry):

@mountiny

Copy link
Copy Markdown
Contributor

There wasn't much to test. This is refactoring.

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.

9 participants