Repository navigation
perf: use per-login selector for DelegateOnBehalfOfText personal details - #96725
Conversation
4b622f8 to
1b5ecda
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4c65c27408
ℹ️ 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".
| return undefined; | ||
| } | ||
| const lowerLogin = login.toLowerCase(); | ||
| return Object.values(personalDetailsList ?? {}).find((detail) => detail?.login?.toLowerCase() === lowerLogin) ?? undefined; |
There was a problem hiding this comment.
Avoid materializing all personal details
On high-traffic accounts with many DelegateOnBehalfOfTextFallback subscribers, this selector still allocates an array containing the entire PERSONAL_DETAILS_LIST every time Onyx evaluates it before .find() can short-circuit. That preserves the per-instance O(all personal details) allocation pressure this change is intended to remove; iterate the record directly and return as soon as the login matches so each fallback subscriber doesn't materialize the full list on every personal-details write.
Useful? React with 👍 / 👎.
Reviewer Checklist
Screenshots/VideosAndroid: HybridApp2026-07-22.14.31.59.movAndroid: mWeb Chrome2026-07-22.14.31.59.moviOS: HybridApp2026-07-22.14.31.59.moviOS: mWeb Safari2026-07-22.14.31.59.movMacOS: Chrome / Safari2026-07-22.14.25.55.mov |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 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! 🧪🧪
|
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.4.43-0 🚀
|
|
🤖 No help site changes required. I reviewed the changes in this PR against the help site articles under Why: This is a purely internal performance refactor. It swaps the
The only externally observable difference is faster render time (~290ms → ~110ms), which isn't something documented on the help site.
|
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.4.43-1 🚀
Bundle Size Analysis (Sentry): |
Explanation of Change
The chat
DelegateOnBehalfOfTextcomponent renders once per relevant report action. Its fallback path calledusePersonalDetailsByLogin, which subscribes to the wholePERSONAL_DETAILS_LISTwithout a selector and rebuilds a full login→details map (Object.values().reduce()) per instance.Two consequences that scale badly with the number of delegate messages on screen:
useOnyxreturns a new reference on every write to the key, so every instance re-rendered whenever anyone's personal details changed.This replaces that call with a
useOnyxselector that returns only the single detail the component needs:personalDetailByLoginSelector(login)— single detail (used byDelegateOnBehalfOfText's fallback), with.findearly-exit.Measured on a screen with many delegate messages: render time ~290ms → ~110ms (~2.6x).
Fixed Issues
$ #96727
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: mWeb Safari
MacOS: Chrome / Safari