Perf: compute transaction violations once in MoneyRequestReportPreviewProvider#96053
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f875d841c
ℹ️ 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".
| function useReportPreviewActionButtonData(iouReportID: string | undefined) { | ||
| const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`); | ||
| const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${iouReport?.policyID}`); | ||
| const [ownerLogin] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: personalDetailsLoginSelector(iouReport?.ownerAccountID)}); |
There was a problem hiding this comment.
Add dependency for owner login selector
This selector depends on iouReport?.ownerAccountID, but the extracted hook dropped the [iouReport?.ownerAccountID] dependency that all three deleted callers passed to useOnyx. When the preview first renders before the report hydrates, or if it is reused for another report, ownerLogin can remain undefined/stale; submit/approve then pass a bad submitterLogin/ownerLogin, which affects approval-chain resolution and duplicate-violation handling. Please pass the owner account ID as the third argument here.
Useful? React with 👍 / 👎.
…-provider-violations-slice
63aa887 to
2202396
Compare
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
…-provider-violations-slice
f6b620d to
4019ac3
Compare
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
|
@linhvovan29546 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] |
linhvovan29546
left a comment
There was a problem hiding this comment.
I think we should add a test for this, since it looks like we don't currently have any test coverage for this scenario.
| jest.mock('@components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContext', () => ({ | ||
| __esModule: true, | ||
| useReportPreviewData: () => mockReportPreviewData, | ||
| useReportPreviewTransactionViolations: () => ({transactionViolations: {}}), |
There was a problem hiding this comment.
So it looks like we don't have any tests covering violations for this file.
| jest.mock('@components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContext', () => ({ | ||
| __esModule: true, | ||
| useReportPreviewData: () => ({iouReportID: TEST_IOU_REPORT_ID, transactions: []}), | ||
| useReportPreviewTransactionViolations: () => ({transactionViolations: {}}), |
There was a problem hiding this comment.
So it looks like we don't have any tests covering violations for this file.
JmillsExpensify
left a comment
There was a problem hiding this comment.
No product review required.
Reviewer Checklist
Screenshots/VideosAndroid: HybridApptelegram-cloud-document-5-6265064963564380846.mp4Android: mWeb Chrometelegram-cloud-document-5-6265064963564380846.mp4iOS: HybridAppScreen.Recording.2026-07-20.at.16.25.15.moviOS: mWeb SafariScreen.Recording.2026-07-20.at.15.53.31.movMacOS: Chrome / SafariScreen.Recording.2026-07-20.at.15.48.58.movScreen.Recording.2026-07-20.at.16.15.48.mov |
|
🚧 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.41-0 🚀
|
|
🤖 I reviewed the changes in this PR and no help site changes are required. This is a pure internal performance refactor: transaction violations are now computed once in Since Expensify's help site articles ( @OlimpiaZurek, if you believe a help site update is warranted here, let me know and I'll draft one — otherwise no action is needed. |
Explanation of Change
The report preview transaction violations were computed in
MoneyRequestReportPreviewProviderand re-selected independently by each ofSubmitActionButton/PayActionButton(each over the whole TRANSACTION_VIOLATIONS collection, re-running on every button render). This exposes the provider's already scopedtransactionViolationsthrough a newReportPreviewTransactionViolationscontext slice and has Submit/Pay consume it, so the selector runs once (in the provider) instead of once per mounted button.ApproveActionButtonkeeps its own violations because its transaction set (useTransactionsAndViolationsForReport, unfiltered) differs from the provider's offline/delete-filtered set.Performance gain:
Fixed Issues
$ #96003
PROPOSAL:
Tests
Offline tests
QA Steps
Same as tests
// TODO: These must be filled out, or the issue title must include "[No QA]."
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