Skip to content

Migrate Workspace Avatar usages - #97465

Merged
roryabraham merged 13 commits into
Expensify:mainfrom
software-mansion-labs:chore/migrate-workspace-avatar-usage
Aug 7, 2026
Merged

roryabraham merged 13 commits into
Expensify:mainfrom
software-mansion-labs:chore/migrate-workspace-avatar-usage

Conversation

@jmusial

@jmusial jmusial commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Migrates call sites with a statically known avatar kind from the legacy Avatar wrapper to WorkspaceAvatar directly.

Changes AvatarButtonWithIcon & AvatarWithImagePicker to accept a ready avatar node instead of rendering the avatar internally from source/type/DefaultAvatar props.

Adds a getAccountIDFromAvatarID helper that safely narrows avatarID to a numeric account ID, rejecting policy-ID-shaped strings whole instead of parsing a bogus leading number.

Drops redundant getDefaultWorkspaceAvatar fallbacks at 9 call sites -WorkspaceAvatar now derives the default from name internally (MenuItem's workspace branch no longer requires icon for this to kick in).

No user-facing behavior change intended; sites with runtime-dynamic icon types keep the wrapper.

Fixed Issues

$ #95599
PROPOSAL:

Tests

Scenario 1

  1. Open app → Worspaces
  2. New workspace → on confirmation screen verify default workspace avatar (first-letter icon, colored background), centered
  3. Create it → workspace initial page opens → verify same default avatar in header next to back button
  4. Go to Overview → verify default avatar, left-aligned, pencil icon on it
  5. Tap avatar → upload corrupt or <80px image → verify error under avatar
  6. Navigate away, come back → verify error gone
  7. Upload valid image → verify avatar updates everywhere (Overview, header, Workspaces list row)
  8. Back in Overview → remove photo → verify default letter avatar returns, same background color as step 2

Offline tests

N/A

QA Steps

Same as tests

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-03.at.17.12.24.mov
Android: mWeb Chrome
Screen.Recording.2026-08-03.at.17.17.10.mov
iOS: Native
Screen.Recording.2026-08-03.at.17.30.40.mov
iOS: mWeb Safari

Uploading Screen Recording 2026-08-03 at 17.31.44.mov…

MacOS: Chrome / Safari
Screen.Recording.2026-08-03.at.17.07.06.mov

@codecov

codecov Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/components/Avatar/index.tsx 100.00% <100.00%> (ø)
src/components/AvatarButtonWithIcon.tsx 100.00% <100.00%> (ø)
src/components/MenuItem.tsx 92.00% <100.00%> (+0.02%) ⬆️
...stConfirmationList/sections/InvoiceSenderField.tsx 92.30% <100.00%> (ø)
...nents/Search/SearchList/ListItem/WorkspaceCell.tsx 94.11% <100.00%> (-0.33%) ⬇️
...ts/Tables/WorkspaceListTable/WorkspaceTableRow.tsx 91.11% <100.00%> (ø)
src/components/Tables/WorkspaceListTable/index.tsx 79.54% <ø> (ø)
src/libs/UserAvatarUtils.ts 97.29% <100.00%> (+0.09%) ⬆️
src/pages/settings/Agents/AddAgentPage.tsx 93.42% <100.00%> (+0.08%) ⬆️
src/pages/settings/Agents/EditAgentPage.tsx 91.17% <100.00%> (ø)
... and 18 more
... and 10 files with indirect coverage changes

@jmusial

jmusial commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: ffd701911e

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

@jmusial

jmusial commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: f829a172bd

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

@jmusial
jmusial marked this pull request as ready for review August 3, 2026 15:33
@jmusial
jmusial requested review from a team as code owners August 3, 2026 15:33
@melvin-bot
melvin-bot Bot requested review from hoangzinh and removed request for a team August 3, 2026 15:33
@melvin-bot

melvin-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

@hoangzinh 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, heyjennahay, parasharrajat and roryabraham and removed request for a team August 3, 2026 15:33
@melvin-bot

melvin-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

@parasharrajat @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]

@melvin-bot
melvin-bot Bot removed the request for review from a team August 3, 2026 15:33

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9ffb29df87

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

Comment thread src/components/MenuItem.tsx
@jmusial

jmusial commented Aug 4, 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: 061d3590cf

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

@hoangzinh

hoangzinh commented Aug 5, 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
Screen.Recording.2026-08-06.at.21.54.08.mov
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-08-06.at.21.46.54.mov

shouldShowRightIcon={!isReadOnly && !!canUpdateSenderWorkspace}
title={senderWorkspace?.name}
icon={senderWorkspace?.avatarURL ? senderWorkspace.avatarURL : getDefaultWorkspaceAvatar(senderWorkspace?.name)}
icon={senderWorkspace?.avatarURL}

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 you elaborate on this change? Why do we need this change?

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.

Now WorkspaceAvatars calculate fallback internally (WorkspaceAvatar.tsx:35-38), so passing defaults on callsites is redundant

);
}

WorkspaceCell.displayName = 'WorkspaceCell';

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.

Should we bring back this line?

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.

not really, it's not doing anything

size = CONST.AVATAR_SIZE.DEFAULT,
type = CONST.ICON_TYPE_AVATAR,
avatar,
size = CONST.AVATAR_SIZE.XXXX_LARGE,

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.

Are we correct to change the default size from CONST.AVATAR_SIZE.DEFAULT to CONST.AVATAR_SIZE.XXXX_LARGE?

@jmusial jmusial Aug 6, 2026 •

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.

On main, old DEFAULT default was dead code - every call site passed size={CONST.AVATAR_SIZE.XXXX_LARGE}

@hoangzinh

Copy link
Copy Markdown
Contributor

Remove the workspace branch and type prop handling from Avatar/index.tsx once complete.

I found this requirement in the original issue. @jmusial Are you planning to do it in another PR?

roryabraham
roryabraham previously approved these changes Aug 5, 2026

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

Overall this all seems like a step in the right direction. I'm a bit shaky on whether a ReactNode as a prop is really a best practice. I think really we want to compose via JSX trees rather than props. But it also seems like to do that would require further decomposition of other components, which we can evaluate separately.

@jmusial

jmusial commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Remove the workspace branch and type prop handling from Avatar/index.tsx once complete.

I found this requirement in the original issue. @jmusial Are you planning to do it in another PR?

Possibly, working through the issue it turned out there are sites that genuinely require User/Workspace avatar. For now I left it using src/components/Avatar/index.tsx and not 100% sure what will be the best way to proceed with them.

I'd suggest dropping this requirement from sub issue and revisiting after #95599 and #95600 are done

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

@melvin-bot
melvin-bot Bot requested a review from roryabraham August 6, 2026 14:57
@roryabraham
roryabraham merged commit e25c305 into Expensify:main Aug 7, 2026
36 of 44 checks passed
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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

@OSBotify

OSBotify commented Aug 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 Aug 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 #97465.

Android 🤖 iOS 🍎
❌ FAILED ❌ https://ad-hoc-expensify-cash.s3.us-east-1.amazonaws.com/rock-artifacts/ad-hoc/rock-ios-device-AdHoc-e25c305-f1b9fa4-758bb92c321f49887819dafe6c7af98f894da28f/index.html
The QR code can't be generated, because the Android build failed iOS
Web 🕸️
https://97465.pr-testing.expensify.com
Web

👀 View the workflow run that generated this build 👀

@OSBotify

Copy link
Copy Markdown
Contributor

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

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes required.

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

This is a purely internal code refactor with no user-facing impact:

  • Migrates call sites with a statically known avatar kind from the legacy Avatar wrapper to WorkspaceAvatar directly.
  • Changes AvatarButtonWithIcon and AvatarWithImagePicker to accept a ready avatar node instead of rendering it internally.
  • Adds a getAccountIDFromAvatarID helper and drops redundant getDefaultWorkspaceAvatar fallbacks.

The PR itself states "No user-facing behavior change intended," and the diff confirms it — there are no src/languages/*.ts edits, no new or changed UI copy, and no changes to any documented feature, workflow, setting, or button label. The only text matches in the diff are unit-test and Storybook descriptions.

Since the help site documents user-facing product behavior (which is unchanged here), no articles need updating and no draft docs PR was created.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.52-11 🚀

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

Bundle Size Analysis (Sentry):

{shouldUseNarrowTableLayout && (
<View style={[styles.flex1, styles.flexRow, styles.gap3, styles.alignItemsCenter]}>
<Avatar
<WorkspaceAvatar

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.

Checklist

This change caused the crash reported in #100204. avatarID can be undefined when switching between the Spend and Workspace pages while inviting a member to a workspace.

item.policyID can be undefined at render time because a new policy_<id> record doesn't arrive all at once, it streams in as several partial Onyx merges, and fields like role can arrive before id does. A render that catches that gap reaches WorkspaceAvatar.tsx:58 with no id to work with.

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.

6 participants