Perf/report preview provider violations slice#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 👍 / 👎.
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