Skip to content

[No QA] Decompose Icon component#95048

Merged
roryabraham merged 3 commits into
Expensify:mainfrom
software-mansion-labs:chore/decompose-icon-compoenent
Jul 7, 2026
Merged

[No QA] Decompose Icon component#95048
roryabraham merged 3 commits into
Expensify:mainfrom
software-mansion-labs:chore/decompose-icon-compoenent

Conversation

@jmusial

@jmusial jmusial commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

This refactors the monolithic Icon component into focused primitives (BaseIcon, InlineIcon, MultiGestureIcon) plus small hooks, and adds a size prop backed by CONST.ICON_SIZE that deprecates the extraSmall/small/medium/large booleans.

The inline (3 call sites) and enableMultiGestureCanvas (1 call site — AttachmentView) branches are kept behavior-identical for backward compatibility.

Given how few call sites use them, both can be migrated out of the Icon API into dedicated components in a future follow-up. Afterwards all other Icon call sites can be migrated to BaseIcon.

Fixed Issues

$ #95156

Tests

For regular icons

  1. Open app
  2. Verify that icons show as on prod ex in LHN, Account -> Security or other places.

For inline icons

  1. Open app
  2. Go to Settings → Security → Two-factor authentication and start/enable the flow.
  3. Verify that after Pressing Copy → label/icon toggle to the "copied" state, icon stays aligned.

For multi gesture icons

  1. On a touch device open app
  2. Upload an svg icon as a either workspace or user s avatar
  3. On "Edit avatar page" click Edit -> View photo
  4. Verify that you can pinch zoom / interact with the icon via gestures

Offline tests

Same as tests.

QA Steps

N/A - Performance oriented refactor, not changing any functionality.

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

Android: Native
Screen.Recording.2026-07-02.at.15.53.42.mov
Android: mWeb Chrome
Screen.Recording.2026-07-02.at.15.56.17.mov
iOS: Native
Screen.Recording.2026-07-02.at.15.29.24.mov
iOS: mWeb Safari
Screen.Recording.2026-07-02.at.15.30.36.mov
MacOS: Chrome / Safari image

@jmusial

jmusial commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 7baf6eca4a

ℹ️ 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".

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
src/CONST/index.ts 93.33% <ø> (ø)
src/components/Icon/primitives/BaseIcon.tsx 100.00% <100.00%> (ø)
src/components/Icon/primitives/InlineIcon.tsx 100.00% <100.00%> (ø)
src/styles/utils/index.ts 54.59% <100.00%> (+0.22%) ⬆️
src/components/Icon/primitives/resolveIconSize.ts 91.66% <91.66%> (ø)
src/components/Icon/index.tsx 90.32% <71.42%> (+4.86%) ⬆️
...rc/components/Icon/primitives/MultiGestureIcon.tsx 0.00% <0.00%> (ø)
src/components/Icon/primitives/useCanvasSize.ts 0.00% <0.00%> (ø)
...components/Icon/primitives/useIconCarouselPager.ts 0.00% <0.00%> (ø)
... and 298 files with indirect coverage changes

roryabraham
roryabraham previously approved these changes Jul 1, 2026
import type {IconSize} from './types';

/** Resolves the effective icon size from the new `size` prop or legacy boolean props. */
function resolveIconSize(size: IconSize | undefined, extraSmall: boolean, small: boolean, medium: boolean, large: boolean): IconSize | undefined {

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.

This function is a bit wonky, and it's not clear to me why it's helpful

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.

seeing how you're using it, it seems fine for now but we should create a follow-up to rip out the deprecated props

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.

Will be addressed in either #95159 or #95158 Whichever comes last

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.

Tracking issue for follow-up: #95601 — [M4] Cleanup Icon legacy size boolean props

Parent: #95157

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.

Tracking issue for follow-up: #95601 — [M4] Cleanup Icon legacy size boolean props

Parent: #95157

import type {Dimensions} from '@src/types/utils/Layout';

/** Tracks the measured layout size of the multi-gesture icon canvas. */
function useCanvasSize() {

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.

Maybe belongs better in the src/components/MultiGestureCanvas directory/"namespace".

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.

Will be addressed in #95158

};

/** Renders an SVG icon with preset sizes, inline layout, and optional gesture support. */
function Icon({

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.

Overall this PR seems like a step in the right direction, but the Icon component is still kind of a configuration-overloaded barrel. Yes, we can use the primitives elsewhere now. But in practice this component still encapsulates all the configuration we had before. A complete decomposition refactor would be a bigger lift - getting rid of this wrapper/config barrel and using the appropriate primitives at each callsite.

I understand that's a larger refactor though, so it doesn't necessarily have to be part of this PR (especially since the primitives being available unblocks decomposition further up the tree)

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.

Yeah, both Icon/index and deprecated props I would like to address in follow ups, then what now is BaseIcon will become Icon and others will just be used directly.

@jmusial jmusial changed the title Decompose Icon component [No QA] - Decompose Icon component Jul 2, 2026
@jmusial jmusial changed the title [No QA] - Decompose Icon component [No QA] Decompose Icon component Jul 2, 2026
@jmusial
jmusial marked this pull request as ready for review July 2, 2026 13:57
@jmusial
jmusial requested review from a team as code owners July 2, 2026 13:57
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and eh2077 and removed request for a team July 2, 2026 13:57
@melvin-bot

melvin-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

@eh2077 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, Pujan92 and roryabraham and removed request for a team July 2, 2026 13:57
@melvin-bot

melvin-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

@Pujan92 @roryabraham One of you needs to 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]

@eh2077

eh2077 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

It seems Melvin occasionally assigned two C+ here.

@roryabraham Do we need C+ review here? I'll proceed C+ review if needed.

@roryabraham

Copy link
Copy Markdown
Contributor

ok, we'll let you work as C+ here @eh2077

@roryabraham
roryabraham removed the request for review from Pujan92 July 2, 2026 17:22
@eh2077

eh2077 commented Jul 6, 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
Screen.Recording.2026-07-07.at.5.03.09.PM.mov
Android: mWeb Chrome
Screen.Recording.2026-07-07.at.4.45.45.PM.mov
iOS: HybridApp
Screen.Recording.2026-07-07.at.5.00.06.PM.mov
iOS: mWeb Safari
Screen.Recording.2026-07-07.at.4.17.29.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-07-07.at.4.19.02.PM.mov

style={StyleSheet.absoluteFill}
onLayout={updateCanvasSize}
>
{!isCanvasLoading && !!canvasSize && (

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.

NAB: I think we can use canvasSize only for simplicity.

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.

done

type IconSize = ValueOf<typeof CONST.ICON_SIZE>;

/** Shared render props for icon primitive components. */
type BaseIconProps = {

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 think we should include size?: IconSize; prop, right?

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.

nah, this is for primitives and they have resolved

                iconWidth={iconWidth}
                iconHeight={iconHeight}

passed

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

tested well, just two minor comments above

@jmusial

jmusial commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

tested well, just two minor comments above

@eh2077 all addressed

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

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

approving and looking forward to the follow-ups discussed above

@roryabraham
roryabraham merged commit 243120a into Expensify:main Jul 7, 2026
37 checks passed
@OSBotify

OSBotify commented Jul 7, 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.

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
Built from App PR #95048.

Android 🤖 iOS 🍎
https://ad-hoc-expensify-cash.s3.us-east-1.amazonaws.com/rock-artifacts/ad-hoc/rock-android-Adhoc-243120adb8a-c9ce36c-4ad48d017eb740b24a2e055becb79e41f5cf4593/index.html ❌ FAILED ❌
Android The QR code can't be generated, because the iOS build failed
Web 🕸️
https://95048.pr-testing.expensify.com
Web

👀 View the workflow run that generated this build 👀

@OSBotify

OSBotify commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/roryabraham in version: 9.4.32-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 against the help site content under App/docs/articles and found no help site updates are required.

Why: This is a purely internal, developer-facing refactor. It decomposes the Icon component into BaseIcon/InlineIcon/MultiGestureIcon primitives and adds a size prop backed by CONST.ICON_SIZE (deprecating the extraSmall/small/medium/large booleans). All touched files are component internals and styles:

  • src/components/Icon/index.tsx and src/components/Icon/primitives/*
  • src/styles/utils/index.ts
  • src/CONST/index.ts (new ICON_SIZE constant)

None of this changes any user-facing feature, workflow, setting, tab, label, or button. The PR is explicitly [No QA] — "Performance oriented refactor, not changing any functionality." The help site articles document product behavior for end users, and nothing documented there is affected.

Since no help site changes are needed, I did not open a draft docs PR.


@jmusial — no linked help site PR was created because this refactor has no user-facing impact. If you believe a specific article is affected, let me know which one and I'll take another look.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/grgia in version: 9.4.32-3 🚀

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