refactor:extract getIsP2PForAmount into AmountSubmission helper#93161
Conversation
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.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7e499c4d8f
ℹ️ 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".
| const iouOrExpenseReport = getReportOrReportDraftForAmount(report?.chatReportID); | ||
| if (iouOrExpenseReport && isMoneyRequestReport(iouOrExpenseReport) && iouOrExpenseReport.chatReportID) { | ||
| return getReportOrReportDraftForAmount(iouOrExpenseReport.chatReportID); |
There was a problem hiding this comment.
Keep P2P detection reactive for edits
When editing an existing expense in a 1:1 DM, this lookup depends on module-level connectWithoutView collection caches that do not trigger a component re-render when they finish loading. If the amount step renders before allReports / allReportDrafts have the IOU report and actual chat report, this falls back to the transaction-thread report, whose only participant is the current user, so MoneyRequestAmountForm receives isP2P=false and allows invalid P2P amounts such as 0. The previous useReportOrReportDraft subscriptions for these exact IDs re-rendered once the reports arrived, so this is a regression for cold/lazy-loaded edit flows.
Useful? React with 👍 / 👎.
|
@Julesssss @cristipaval 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] |
|
PR doesn’t need product input as a refactor PR. Unassigning and unsubscribing myself. |
|
Hi @Pujan92 are you able to review please |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-06-12.at.17.51.02.mov |
| selectedTab={iouRequestType as SelectedTabRequest} | ||
| chatReportID={reportID} | ||
| isP2P={isParticipantP2P(getMoneyRequestParticipantsFromReport(chatReportForP2PCheck, currentUserPersonalDetails.accountID).at(0))} | ||
| isP2P={getIsP2PForAmount({chatReportForP2P: chatReportForP2PCheck, currentUserAccountID: currentUserPersonalDetails.accountID})} |
There was a problem hiding this comment.
wondering what we are achieving here by moving this to separate fun getIsP2PForAmount?
There was a problem hiding this comment.
The function itself is small, but moving it into AmountSubmission.ts is what makes the module a place to keep the REPORT and REPORT_DRAFT data outside the component, which removes the 2 subscriptions the screen used to set up on every mount. Follow-up PRs will move more submit only data into the same file, and eventually the submit handler itself
|
Ready for your review on Monday @cristipaval |
|
🚧 @cristipaval has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/cristipaval in version: 9.4.8-0 🚀
Bundle Size Analysis (Sentry): |
|
🤖 No help site changes required. This PR is an internal code refactor with no user-facing impact:
The PR description explicitly notes "No behavior change", and the diff confirms it — no new features, UI elements, tab/setting labels, or flows were added or modified. Nothing in No draft docs PR was created since there is nothing to document. @OlimpiaZurek, if you believe this refactor surfaces a user-facing behavior that the help site should document, let me know and I'll draft the docs PR. |
|
🚀 Deployed to staging by https://github.com/cristipaval in version: 9.4.8-0 🚀
Bundle Size Analysis (Sentry): |
|
🚀 Deployed to production by https://github.com/puneetlath in version: 9.4.8-3 🚀
|
Explanation of Change
This PR extracts P2P-chat resolution helpers out of IOURequestStepAmount into a small helper module. Removes 2 mount-time Onyx subscriptions from the screen and lays the groundwork for follow-up decomposition PRs. No behavior change.
Part 3/6 of #92411.
Fixed Issues
$ #92411
PROPOSAL:
Tests
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
[x] I linked the correct issue in the
### 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