perf: defer personal details weighting in SuggestionMention#88332
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.
|
|
@abzokhattab 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: 0c61f0179e
ℹ️ 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".
|
@codex review |
|
@MelvinBot review the pr |
…on-defer-weighting
|
🤖 PR Review Logic bug in the weighting condition — the refactor changes behavior, not just timing. Old code (removed if (!isGroupChat(currentReport) && !doesReportBelongToWorkspace(currentReport, ...)) {
return personalDetails; // skip weighting
}
// weighting applied when: isGroupChat || doesReportBelongToWorkspace (De Morgan's)New code: const shouldWeightDetails = isGroupChat(currentReport) && doesReportBelongToWorkspace(currentReport, ...);The old code weights when either condition is true ( Fix: change const shouldWeightDetails = isGroupChat(currentReport) || doesReportBelongToWorkspace(currentReport, policyEmployeeAccountIDs, policyID, conciergeReportID);Everything else looks good — dependency array is complete, the single call site is updated, imports are correct, and the perf win (deferring O(n) allocation off the render path) is real and well-motivated. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c75655f460
ℹ️ 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".
|
Let's add a few unit tests to cover the |
i think this step in the PR description was overlooked i think you mean |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-04-21.at.01.37.57.movAndroid: mWeb ChromeScreen.Recording.2026-04-21.at.01.41.15.moviOS: HybridAppScreen.Recording.2026-04-21.at.01.37.57.moviOS: mWeb SafariScreen.Recording.2026-04-21.at.01.41.15.movMacOS: Chrome / SafariScreen.Recording.2026-04-21.at.01.36.32.mov |
…on-defer-weighting
|
@abzokhattab updated, thanks! |
|
🚀🚀 |
|
🚧 @mountiny 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/mountiny in version: 9.3.61-0 🚀
Bundle Size Analysis (Sentry): |
|
I reviewed the changes in this PR. This is a purely internal performance optimization that defers personal details weighting in No help site changes are required. |
Explanation of Change
On accounts with a large number of personal details (~17k), opening a report (especially invoice reports) spent significant time inside
SuggestionMentioncomputingweightedPersonalDetailsvia auseMemo. That memo ran on every render and spread-copied all personal details ({...detail, weight}) even when the user was not typing a mention.This PR defers the weighting until a mention is actually being resolved:
weightedPersonalDetailsat render timegetPersonalDetailsWeightand the weighted-details computation inline insidegetUserMentionOptions, which only runs inside the debouncedcalculateMentionSuggestionwhenprefixType === '@'andisMentionCodepasses.getUserMentionOptionsnow takes onlysearchValueinstead of a pre-built weighted map.No UI change. Same inputs → same outputs. The O(17k) allocation cost shifts off the render path onto the already-debounced keystroke path, so for large accounts the render-time cost of this computation drops to 0.
On account with 17k personal details, average time of
ManualOpenReporton opening the invoice drops from 2.16s to 1.87s (~13% improvement)Fixed Issues
$ #88334
PROPOSAL:
Tests
Offline tests
N/A
QA Steps
Same as tests
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