Fix double-computation of requiresAttentionFromCurrentUser in LHN filter loop#84005
Conversation
… value is available
|
@sobitneupane 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] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 209c16e9c9
ℹ️ 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".
| } | ||
|
|
||
| if (requiresAttentionFromCurrentUser(report, undefined, isReportArchived)) { | ||
| if (requiresAttention ?? requiresAttentionFromCurrentUser(report, undefined, isReportArchived)) { |
There was a problem hiding this comment.
Recompute attention when cached flag can be stale
Using requiresAttention ?? ... makes a cached false value authoritative, but the derived reportAttributes cache is not refreshed for policy-only changes (reportAttributes compute builds updates from report/reportAction/transaction keys and returns early when only POLICY changes). Since requiresAttentionFromCurrentUser() depends on getPolicy(...).reimbursementChoice, a workspace reimbursement setting change can make a report actionable while requiresAttention remains stale false, and this branch will now suppress it from LHN/GSD instead of recalculating.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actually the problem is not in this file, but in reportAttributes.ts. The mentioned derived value has policies on their dependency list, but never recompute these values when anything in policy change.
@sobitneupane @shubham1206agra do you think I should modify reportAttributes.ts?
There was a problem hiding this comment.
@sosek108 Can you put this in #quality channel with impact so we can discuss this?
| isReportArchived: boolean | undefined; | ||
| draftComment: string | undefined; | ||
| /** Pre-computed value from reportAttributes derived value. When provided, skips the expensive requiresAttentionFromCurrentUser recomputation. */ | ||
| requiresAttention?: boolean; |
There was a problem hiding this comment.
@sosek108 Can you make this a required parameter? This will help us remove null check from below. NAB but it's good to have.
There was a problem hiding this comment.
we want to have this optional as a fallback. And the check below is important so we know if we need to recompute this value.
| const isFocused = report.reportID === currentReportId; | ||
| const chatReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`]; | ||
| const parentReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`]; | ||
| const hasErrorsOtherThanFailedReceipt = hasReportErrorsOtherThanFailedReceipt(report, chatReport, doesReportHaveViolations, transactionViolations, transactions, reportAttributes); |
…quires-attention-v2
Reviewer Checklist
Screenshots/VideosScreen.Recording.2026-03-10.at.7.42.37.PM.mov |
JmillsExpensify
left a comment
There was a problem hiding this comment.
Product behavior outlined in the testing steps looks good.
|
🚧 @NikkiWines has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/NikkiWines in version: 9.3.41-0 🚀
Bundle Size Analysis (Sentry): |
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.3.41-4 🚀
|


Explanation of Change
shouldDisplayReportInLHNalready had the pre-computedrequiresAttentionvalue available viareportAttributes[reportID].requiresAttention(derived by OnyxDerived), but it was not being forwarded intoshouldReportBeInOptionList. As a result,reasonForReportToBeInOptionListwas recomputing the value from scratch on every call by invokingrequiresAttentionFromCurrentUser→getReasonAndReportActionThatRequiresAttention→getIOUReportActionToApproveOrPay, the last of which does an O(n)Object.values.findscan over all report actions — repeated for every report in the LHN loop.The fix adds an optional
requiresAttention?: booleanfield toShouldReportBeInOptionListParams. When the caller supplies it,reasonForReportToBeInOptionListuses it directly viarequiresAttention ?? requiresAttentionFromCurrentUser(...), skipping the expensive recomputation.shouldDisplayReportInLHNnow passes the pre-computed value fromreportAttributes.Fixed Issues
$ #83043
PROPOSAL:
Tests
Offline tests
N/A
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
Android: Native
Android: mWeb Chrome
iOS: Native
ios.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
wb.mov