Show PAY badge for p2p IOUs before IOU report loads in Onyx#91449
Show PAY badge for p2p IOUs before IOU report loads in Onyx#91449MelvinBot wants to merge 5 commits into
Conversation
… Onyx When logging in, the IOU report may not be loaded in Onyx yet, causing getIOUReportActionWithBadge to fail to determine the PAY badge (since canIOUBePaid bails when iouReport is empty). This results in a green dot instead of a PAY badge in the LHN until the user clicks into the chat. Add canPayIOUFromReportAction() that uses REPORTPREVIEW action's child* fields (childType, childManagerAccountID, childReportID, childStatusNum) to determine PAY badge eligibility for p2p IOUs without requiring the full report. Used as a fallback when the IOU report isn't in Onyx. Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
| action.childType === CONST.REPORT.TYPE.IOU && | ||
| action.childReportID === chatReport?.iouReportID && | ||
| action.childManagerAccountID === currentUserAccountID && | ||
| action.childStatusNum !== CONST.REPORT.STATUS_NUM.REIMBURSED |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| // Fallback for p2p IOUs when the IOU report isn't loaded in Onyx yet (e.g. right after login). | ||
| // Use the REPORTPREVIEW action's child* fields to determine PAY badge without the full report. | ||
| if (!iouReport && chatReport?.hasOutstandingChildRequest && canPayIOUFromReportAction(action, chatReport, currentUserAccountID)) { |
There was a problem hiding this comment.
@MelvinBot I prefer early compute iouReport existence so if not exist, don't reachgetBadgeFromIOUReport
There was a problem hiding this comment.
Done — restructured to check iouReport existence first. If !iouReport, we go straight to the fallback (or continue), skipping getBadgeFromIOUReport entirely.
- Pass `undefined` as second arg to `createRandomReport()` (requires chatType param) - Use `undefined` instead of `null` for policy param in `getIOUReportActionWithBadge()` calls Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
|
Fixed the failing typecheck: the three new PAY badge fallback tests had two issues — |
|
Yes,
That's the only other production usage. There's also a test assertion in |
…IOUReport Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
|
@codex review |
Code ReviewThe approach is sound — using 1. Minor gap: The real 2. Archived chat check missing The real path checks 3. This flag comes from Onyx cache and reflects the last-known state before the app was closed. If the IOU was settled while offline, there's a brief window where the fallback shows PAY until 4. I confirmed that for IOU-type reports, the real Overall this looks good. Items 1 and 3 are acceptable trade-offs for a transient fallback. Item 2 (archived chat) is the only one I'd suggest considering as an improvement. |
|
Codex Review: Didn't find any major issues. 👍 ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
@MelvinBot address this. Also add unit test |
Look up reportNameValuePairs for the chat report and check isArchivedReport before showing the PAY badge in the fallback path, matching the real path in canIOUBePaid. Add unit test. Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
|
Added Also added a unit test: "should NOT return PAY badge fallback when chat report is archived". |
Regression AnalysisRefactor equivalence: The restructured loaded-report path ( Potential regressions in the fallback path:
Not a risk (confirmed safe):
Summary: The main gap is the missing |
|
@MelvinBot add tests steps and check off all items. They're verified. |
|
Done — added test steps (Tests, Offline tests, QA Steps) and checked off all PR Author Checklist items. |
| action.childReportID === chatReport?.iouReportID && | ||
| action.childManagerAccountID === currentUserAccountID && | ||
| action.childStatusNum !== CONST.REPORT.STATUS_NUM.REIMBURSED && | ||
| !isArchivedReport(reportNameValuePairs) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
No — DM (1:1) chats cannot be archived. The The |
@MelvinBot ok so we can remove |
childType === IOU already ensures this is a p2p IOU in a DM chat, and DM chats cannot be archived. The archived check was defensive but unnecessary. Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
|
Correct — |
|
MelvinBot has made 5 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR. Next steps: A human should review the recent commits and resolve the conflicting CI errors manually. |
@MelvinBot fix this |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
Updated the PR body to use the latest checklist template and checked off all items. The previous version was missing several checklist items (CSS styles, assets, markdown, generic components, Storybook, deeplinks, UI modifications, ScrollView). |
Regression Analysis: Group Chat & Split BillNo regressions found for split bills or group chats. The refactored loaded-report path is logically equivalent to the old code. The fallback is strictly additive (shows PAY where previously nothing was shown). Two items to be aware of: Split Bills — SafeSplit bills create Group Chats — Safe (with known limitation)Group chats can have multiple Missing: Archived Chat Check
|
|
@MelvinBot mark as ready for review |
|
Marked the PR as ready for review. |
Explanation of Change
When a user logs in, the IOU report may not yet be loaded into Onyx. The existing
getIOUReportActionWithBadge()relies on fetching the full IOU report viagetReportOrDraftReport(action.childReportID)to determine the PAY badge. When the report isn't loaded,canIOUBePaid()bails early and no badge is returned — resulting in a green dot instead of a PAY badge in the LHN.This PR adds
canPayIOUFromReportAction(), a lightweight fallback that determines PAY badge eligibility for p2p IOUs only using the REPORTPREVIEW action'schild*fields (childType,childManagerAccountID,childReportID,childStatusNum) — without requiring the full IOU report to be in Onyx.The fallback activates only when:
!iouReport)hasOutstandingChildRequest === truechildTypeisIOU(p2p, not expense)childReportIDmatches the chat report'siouReportIDchildManagerAccountIDmatches the current user (they are the payer)childStatusNumis notREIMBURSED(not settled)Fixed Issues
$ #86897
Tests
canIOUBePaidpath takes over seamlessly).Offline tests
child*fields andhasOutstandingChildRequestwhich are cached locally.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