Repository navigation
Remove Onyx.connect() for the key: ONYXKEYS.COLLECTION.REPORT in src/libs/ReportUtils.ts (part 9) - #94628
Conversation
|
@DylanDylann 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] |
| amount: item.amount, | ||
| paymentType: resolvedPaymentType, | ||
| ...(isInvoiceReport(item.reportID) | ||
| ...(isInvoiceReport(allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${item.reportID}`]) |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
The inline lookup allReports?.[${ONYXKEYS.COLLECTION.REPORT}${item.reportID}] is duplicated here and again on line 1096 (isItemInvoice). It also re-derives a report that is already resolved into the local iouReport variable a few lines above (const iouReport = getReportFromSearchSnapshot(item.reportID, searchData, allReports)). Worse, this direct allReports access bypasses the snapshot-aware resolution that getReportFromSearchSnapshot performs (it prefers searchData over allReports), so the two code paths can resolve to different reports for the same item.
Reuse the already-resolved report instead of duplicating the lookup:
const iouReport = getReportFromSearchSnapshot(item.reportID, searchData, allReports);
if (!iouReport) {
continue;
}
// ...
...(isInvoiceReport(iouReport)
? getPayMoneyOnSearchInvoiceParams(...)
: {}),
// ...
const isItemInvoice = isInvoiceReport(iouReport);Reviewed at: 8318f93 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8318f93f8d
ℹ️ 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 nextStep = allNextSteps?.[`${ONYXKEYS.COLLECTION.NEXT_STEP}${item.reportID}`]; | ||
| const additionalOnyxData = getSearchPayOnyxData(hash, item.reportID, currentSearchKey); | ||
| const isItemInvoice = isInvoiceReport(item.reportID); | ||
| const isItemInvoice = isInvoiceReport(allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${item.reportID}`]); |
There was a problem hiding this comment.
Use the selected snapshot report for invoice payments
When bulk-paying an invoice that is present in the current search snapshot but not in allReports, this check returns false even though iouReport was already resolved via getReportFromSearchSnapshot above. That sends the invoice through the normal payMoneyRequest path and also skips the invoice-specific payment params built above, so search bulk pay can fail or pay with the wrong flow for invoice results that only exist in the snapshot. Use the resolved iouReport for invoice detection here and when constructing paymentItem.
Useful? React with 👍 / 👎.
|
PR doesn’t need product input as a refactor PR. Unassigning and unsubscribing myself. |
|
@truph01 This is a tough refactor since the report collection is big one. Could you consider putting this PR on hold and doing one PR at a time instead? |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2fa3d2e7b6
ℹ️ 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".
|
|
||
| // Invoice expense is not auto-categorized | ||
| if (isInvoiceReport(transaction.reportID)) { | ||
| if (isInvoiceReport(report)) { |
There was a problem hiding this comment.
Require the report before excluding invoice categories
When this helper is invoked with only a transaction, the signature still allows it and the existing TransactionUtilsTest covers that case by writing an invoice report to Onyx first; this new check receives undefined, so invoice transactions with a missing category and pending ADD fall through and are treated as “category being analyzed” even though invoice expenses are explicitly excluded. Make the report argument required/update all callers and tests to pass it, or otherwise preserve the report lookup for this case.
Useful? React with 👍 / 👎.
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.
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bd14aab1ad
ℹ️ 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".
|
@DylanDylann This PR is ready for review again |
| const isExpenseReport = isExpenseReportUtil(itemReportID); | ||
| const isIOUReport = isIOUReportUtil(itemReportID); | ||
| const reportType = getReportType(itemReportID); | ||
| const reportType = getReportType(itemReportID, itemReport); |
There was a problem hiding this comment.
Let's remove itemReportID
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| report.canPay && | ||
| getReportType(report.reportID) === getReportType(firstReport?.reportID) && | ||
| shouldShowBulkOptionForRemainingTransactions(selectedTransactions, selectedReportIDs, transactionKeys), | ||
| (report) => report.canPay && report.type === firstReport?.type && shouldShowBulkOptionForRemainingTransactions(selectedTransactions, selectedReportIDs, transactionKeys), |
There was a problem hiding this comment.
OLD: getReportType(report.reportID) === getReportType(firstReport?.reportID)
NEW: report.type === firstReport?.type
2 above conditions are not the same. If report.type is CHAT and firstReport?.type is TASK. The old logic returns true, but the new logic returns false
| getReportType(selectedTransactions[transactionIDKey].reportID) === getReportType(firstTransaction?.reportID), | ||
| selectedTransactions[transactionIDKey].report?.type === firstTransaction?.report?.type, |
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ 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". |
|
@DylanDylann All yours! |
Reviewer Checklist
Screenshots/VideosScreen.Recording.2026-09-11.at.15.19.00.mov |
|
🚧 Gonals 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/Gonals in version: 9.4.77-0 🚀
|
|
🤖 No help site changes are required for this PR. No draft docs PR was created. Why: This is a pure internal refactor. It removes the
Callers in What I checked
@truph01, no linked help site PR was needed here — please confirm you agree this refactor is behavior-neutral. If you believe a user-facing behavior did change, reply with the detail and I'll open the docs PR. view run · no recording available |
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.4.77-4 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
Remove Onyx.connect() for the key: ONYXKEYS.COLLECTION.REPORT in src/libs/ReportUtils.ts.
Target call chains:
Fixed Issues
$ #66416
PROPOSAL:
Tests
Analyzing...label in category row"Offline tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand 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
MacOS: Chrome / Safari
Screen.Recording.2026-08-06.at.16.27.39.mov