Skip to content

ReportActionAvatars - ReportActionItemSingle migration - #105254

Merged
roryabraham merged 8 commits into
Expensify:mainfrom
software-mansion-labs:chore/action-avatar-extract-hooks
Nov 7, 2026
Merged

roryabraham merged 8 commits into
Expensify:mainfrom
software-mansion-labs:chore/action-avatar-extract-hooks

Conversation

@jmusial

@jmusial jmusial commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

ReportActionItemSingle used to call useReportActionAvatars twice per row, once for the header and once inside ReportActionAvatars. Now it calls a new useActionAvatar hook once and renders the avatar layout directly.

IOU and invoice previews go through useIOUReportIcons and useInvoiceReportIcons, which are extracted from IOUReportAvatar and InvoiceReportAvatar.

Behavior changes:

  • The avatar label (accessibility label) of an invoice preview without a workspace now reads the sender's login instead of their account ID.
  • When an invoice's room hasn't loaded its policyID yet but the invoice has one, the preview shows the sending workspace instead of the sender, as InvoiceReportAvatar already does in the LHN.

Fixed Issues

$ #94588
PROPOSAL:

Tests

In each chat below, check that the message avatars and sender names look the same as on main.

  1. In a DM, send a message. You see your avatar and name, and clicking it opens your profile.
  2. In a DM, request money, then have the other person add an expense to the same report. The preview shows both avatars diagonally, the header reads "A & B", and clicking it opens the participants list.
  3. In a workspace chat, submit an expense. The preview shows your avatar with the workspace as a subscript.
  4. Send an invoice. The preview shows the workspace with the receiver as a subscript, and clicking it opens the workspace details.
  5. Send a message as a copilot. The copilot badge and the "on behalf of" text show.
  6. With auto-approve on, submit an expense. The approval row shows Concierge in the inbox and the real approver in Search.
  7. Search type:chat and open the chat from step 2. Both avatars still show.

Offline tests

Go offline and change your avatar. Your message avatars show as pending, and the pending state clears once you're back online.

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 verified any copy / text that was added to the app 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 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 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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
action-avatar-retest-android.mp4
Android: mWeb Chrome
action-avatar-retest-android-chrome.mp4
iOS: Native
action-avatar-retest-ios.mp4
iOS: mWeb Safari
action-avatar-retest-ios-safari.mp4
MacOS: Chrome / Safari
action-avatar-retest.mp4

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Coverage Δ
...rc/components/Avatar/connected/IOUReportAvatar.tsx 100.00% <100.00%> (ø)
...omponents/Avatar/connected/InvoiceReportAvatar.tsx 100.00% <100.00%> (ø)
...c/components/Avatar/connected/useIOUReportIcons.ts 100.00% <100.00%> (ø)
...ponents/Avatar/connected/useInvoiceReceiverIcon.ts 100.00% <100.00%> (ø)
...mponents/Avatar/connected/useInvoiceReportIcons.ts 100.00% <100.00%> (ø)
src/pages/inbox/report/ReportActionItemSingle.tsx 92.00% <100.00%> (+0.08%) ⬆️
src/components/Avatar/connected/useActionAvatar.ts 93.87% <93.87%> (ø)
... and 14 files with indirect coverage changes

@jmusial

jmusial commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

Review

The PR looks good overall. IOU previews and ordinary messages render the same as on main. Invoice previews change in more cases than the PR description says. I found two things you should address and one minor note.

1. Invoice previews with no workspace policyID change more than the label. When neither the invoice room nor the invoice has a policyID, useInvoiceReportIcons.ts:73 returns {id: 0, name: '', source: FallbackAvatar}. On main, the generic hook showed the sender instead. That causes these changes:

  • The avatar was the sender's real avatar. Now it is the generic fallback avatar.
  • The header was the sender's display name. Now headingText is empty, so ReportActionItemSingle.tsx:112-119 falls back to action.person.
  • The header fragment's accountID was the sender's ID. Now it is 0.
  • The old accessibility label was the sender's account ID as digits, not a name. The email label is still an improvement.

The same changes go the other way when the room loads without a policyID but the invoice has one. Line 71 falls back to invoice.policyID, so the row now shows the workspace where main showed the person. Both cases look like loading or optimistic states. If the new behavior is intended, please list it in the description.

2. useInvoiceReportIcons ignores the action you already have. hasReportPreview comes from the room's REPORT_ACTIONS (line 58), not from the preview action passed to useActionAvatar. If that lookup misses (for example, on Search when the snapshot invoice has no matching parentReportActionID), you get these regressions:

  • Business-to-business invoice: avatarType is still MULTIPLE (useActionAvatar.ts:242-247), so the header names both workspaces. But the layout falls to SUBSCRIPT (lines 78-84). On main, the row showed both workspaces diagonally.
  • Archived invoice to a person, with more than one sender: isReceiverHidden (line 76) hides the receiver. On main, the receiver showed as a subscript.

To fix both, pass the preview action into useInvoiceReportIcons, the way useIOUReportIcons already accepts reportPreviewAction for Search.

3. Minor: the child report's policyID now applies only to report previews. On main, useReportActionAvatars read action.childReportID's policyID for any action that has a child report. useActionAvatar.ts:184 now reads it only for report previews. The output changes only when the child report's policy differs from its parent's, for example a trip room on a different policy than its workspace chat. App keeps those aligned, so this is low risk, but the "follows useReportActionAvatars" comment isn't strictly accurate.

What I checked and found equivalent

I compared the old useReportActionAvatars + ReportActionAvatars render on main with the new path. I read the code only. I didn't run the app or the tests.

  • IOU previews: layout, icons, header, diagonal order, copilot badge, press target, and accessibility label all match. The old header already showed "Alice & " (with a trailing ampersand) when the owner had no display name, so that isn't new. One rare difference: if the IOU report stores managerID: 0, the header becomes " & Owner" (with a leading ampersand). The old header hook read the report through getStableReportSelector, which turns 0 into undefined.
  • Other actions: the narrower policy selector is safe because getIcons, getWorkspaceIcon, and getInvoiceReceiverIcons read only name and avatarURL. The group-chat and moved-preview subscriptions, layout mapping, Concierge copilot suppression, human-agent subscript, and render props (isHovered, styles, backdrop) all match.
  • Side benefit: the avatar and header now come from one call. On main, they could disagree, for example in invoice-room threads and trip previews.

@jmusial

jmusial commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@MelvinBot recheck plz

@MelvinBot

Copy link
Copy Markdown
Contributor

Recheck

All three points are addressed in 7ef1b5b. I found nothing new that blocks the PR.

  1. Invoice preview with no workspace: fixed. The sender now stands in for the missing workspace (useActionAvatar.ts:244-248), so the avatar, header, and account match main again. The new test compares this case against the legacy hook. The other two changes are now in the description: the login label, and the workspace showing when only the invoice has a policyID.
  2. Search / missing room actions: fixed. useInvoiceReportIcons now takes the preview action and skips the room lookup when it has one (useInvoiceReportIcons.ts:62-76). A new test scenario covers it.
  3. Child report policyID: fixed. It is read for every action again (useActionAvatar.ts:187), and a new test covers a thread on another workspace.

The new personal-details selectors in useIOUReportIcons and useInvoiceReceiverIcon look correct:

  • They cover every account the hooks read.
  • They return undefined when the snapshot list is missing, so the fallback to the live list still works.

usePersonalDetailsByIDs would break that fallback, so the inline selector is the right choice.

Non-blocking edge case: the sender stand-in is applied after useInvoiceReportIcons computes isBusinessToBusiness and layout. For a business-to-business invoice with no sending workspace on either the room or the invoice, the row renders as a subscript. On main it rendered diagonally with the header "Person & Workspace". Invoices are always sent from a workspace, so you can ignore this unless you want exact parity.

CI: test (job 1) and the perf tests were still running when I checked. Check independent approval is the only failure, and it is expected until someone approves the PR.

@jmusial
jmusial marked this pull request as ready for review October 29, 2026 14:20
@jmusial
jmusial requested review from a team as code owners October 29, 2026 14:20
@melvin-bot
melvin-bot Bot requested review from heyjennahay and suneox and removed request for a team October 29, 2026 14:20
@melvin-bot

melvin-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown

@suneox 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 removed the request for review from a team October 29, 2026 14:20
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T14:39:46.002316Z 7ef1b5b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@suneox

suneox commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

I lost track of this PR on the K2 extension. I'll prioritize reviewing it today

@suneox

suneox commented Nov 4, 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 any copy / text that was added to the app 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 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 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.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • 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
az_recorder_20261105_161502.1.mp4
Android: mWeb Chrome
az_recorder_20261105_161936.2.mp4
iOS: HybridApp
CleanShot.2026-11-05.at.16.49.31.4.mp4
iOS: mWeb Safari
CleanShot.2026-11-05.at.16.49.31.4.mp4
MacOS: Chrome / Safari
CleanShot.2026-11-05.at.16.13.48.3.mp4
CleanShot.2026-11-05.at.16.52.41.6.mp4
Automation Same Onyx data rendered on this PR (with `main` merged) and on `main`: layout, header, accessibility label and navigation target match in every case
Case Result
DM message → profile Single avatar, own name, opens /a/<accountID>
IOU report preview, two senders Diagonal, "Alice Sender & me", opens participants
Workspace chat expense preview My avatar + workspace subscript
Invoice to a person Workspace + receiver subscript, opens workspace details
Business-to-business invoice Both workspaces diagonally, "Sender Workspace & Receiver Workspace"
Copilot message "on behalf of" + copilot avatar
Concierge human agent Concierge + agent subscript, "assisted by"
Offline, avatar pending Avatar dims while pending, clears afterward
web.mp4

@suneox

suneox commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

The implementation LGTM. I just found an existing bug while testing as a copilot, It also happens on staging, so it should be tracked as a separate issue:

  • Inside the report opened from that preview, the same message shows the account's own name and avatar instead of the copilot's. (3:15 -> 3:35)
  • In the chat that holds the report preview, a message sent as a copilot shows the copilot's name and avatar with "on behalf of" the account. (3:35 -> 3:45)
Inconsistent display & avatar
CleanShot.2026-11-05.at.16.52.41.6.mp4

So this isn't a blocker for moving this PR forward

@melvin-bot
melvin-bot Bot requested a review from roryabraham November 5, 2026 10:51
* IOU and invoice report previews come from their report's avatar hooks. Every other action follows the rules of `useReportActionAvatars`,
* subscribing only to what its kind of action reads.
*/
function useActionAvatar({action: passedAction, report, shouldUseRealActor}: UseActionAvatarParams): ActionAvatarData {

@roryabraham roryabraham Nov 7, 2026 •

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.

Didn't see anything obvious, but this is a super complex hook that's doing a ton for something that runs on every ReportAction in a chat or report view. We should look closer at it in a follow-up.

@roryabraham
roryabraham merged commit 74b0343 into Expensify:main Nov 7, 2026
37 of 39 checks passed
@github-actions

github-actions Bot commented Nov 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 Nov 7, 2026

Copy link
Copy Markdown
Contributor

@OSBotify OSBotify mentioned this pull request Nov 7, 2026
85 tasks done
@OSBotify

OSBotify commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

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

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

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed — this PR refactors avatar rendering and fixes invoice accessibility labels and loading-state behavior without adding a workflow or making any existing article sentence incorrect.


view run

@MelvinBot

Copy link
Copy Markdown
Contributor

No FullStory changes needed — this PR refactors avatar rendering and fixes invoice accessibility labels and loading-state fallbacks without adding new user flows, controls, screens, or tracking requirements.


view run

@OSBotify

OSBotify commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.34-1 🚀

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.

5 participants