Fix IOU avatar combined when manual and scan expenses from same user#86232
Fix IOU avatar combined when manual and scan expenses from same user#86232
Conversation
…rom the same user Use actorAccountID from iouActions as primary strategy for determining if all transactions are from the same creator. Fall back to sign-based check with scan-awareness: skip scan-in-progress transactions (amount=0) from sign comparison since their direction is unknown until SmartScan completes. Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
|
Fixed the failing ESLint check: the test file used |
|
The previous check failures (ESLint + TypeScript) in |
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.
|
|
@MelvinBot close this PR |
|
Closed this PR as requested by |
Explanation of Change
When a user sends both a manual expense and a scan expense in a 1:1 chat, the IOU avatar incorrectly shows both users instead of just the sender. This happens because scan-in-progress expenses have
amount=0, andMath.sign(0)=0creates a distinct value in the sign comparison set, makingareAmountsSignsTheSame=false.This PR fixes the sender detection logic in
useReportPreviewSenderIDwith a two-tier approach:iouActionsare available, useactorAccountIDto determine if all transactions were created by the same user (most reliable).iouActionsaren't loaded yet, use the sign-based check but with scan-awareness — scan-in-progress transactions with no usable amount are excluded from the comparison rather than contributingMath.sign(0)=0.Fixed Issues
$ #82488
PROPOSAL: #82488 (comment)
Tests
Offline tests
Offline behavior is not directly affected. The fix improves avatar display when
iouActionsare not yet loaded (which can happen offline or on first login). When offline, the fallback sign-based path handles scan transactions gracefully by excluding zero-amount scans from the comparison.QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari