perf: stabilize ReportActionItem with getStableReportSelector and index context#91296
perf: stabilize ReportActionItem with getStableReportSelector and index context#91296LukasMod wants to merge 5 commits into
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 683bb63e10
ℹ️ 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 ReportActionItemMessageEdit({action, reportID, originalReportID, policyID, index, isGroupPolicyReport, shouldDisableEmojiPicker = false, ref}: ReportActionItemMessageEditProps) { | ||
| function ReportActionItemMessageEdit({action, reportID, originalReportID, policyID, isGroupPolicyReport, shouldDisableEmojiPicker = false, ref}: ReportActionItemMessageEditProps) { | ||
| const index = useContext(ReportActionIndexContext); |
There was a problem hiding this comment.
Preserve edit index outside list context
ReportActionItemMessageEdit now reads index only from ReportActionIndexContext, whose default value is 0. ReportActionItem is rendered in flows that are not wrapped by that provider (for example src/pages/TransactionDuplicate/DuplicateTransactionItem.tsx and src/components/Search/SearchList/ListItem/ChatListItem.tsx), so those paths will treat every edited action as index 0 and useEditMessage will incorrectly execute scrollToIndex(0) on save/cancel for non-first items, causing scroll jumps/regressed edit behavior compared to the prior explicit index prop plumbing.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
ChatListItem: old code wasitem.index ?? 0, but search never populatesitem.index,always undefined → always 0. Same as today.DuplicateTransactionItem: renders IOU previews, notReportActionItemMessageEdit; no reportflatListRefin that modal anyway.
|
@jayeshmangwani 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] |
|
No product review needed |
Explanation of Change
1.
getStableReportSelectorA
useOnyxselector that strips heartbeat-style fields from aReport(lastMessageText,lastVisibleActionCreated,lastReadTime,lastReadSequenceNumber,lastMentionedTime,lastVisibleActionLastModified,lastMessageHtml,lastActorAccountID,lastActionType). Subscribed components stop re-rendering on heartbeat-only Onyx pushes.Applied at 4 production
useOnyxsubscription sites:MoneyRequestReportActionsList— expense report scrollReportActionsList— chat scrollReportActionItem(originalReportsubscription) — runs per visible actionChatListItem— search results list2.
ReportActionIndexContext(src/pages/inbox/report/ReportActionIndexContext.tsx)A tiny React context that carries the action item's position index from the list renderer to the rare consumers that read it (
ReportActionItemMessageEditfor scroll-to-index during edit mode). Replaces prop drilling — a new message arriving no longer cascades index re-renders through every item.3. Whisper-handler fix (
MentionWhisperContent,ReportMentionWhisperContent,ConfirmWhisperContent)resolveActionableMentionWhisper/resolveActionableReportMentionWhisper/resolveActionableMentionConfirmWhisperbuild a failure-revert payload fromreport.lastMessageText/lastVisibleActionCreated/lastActorAccountID. Those are exactly the heartbeat fields the selector strips. Without a fix, an API failure would merge{lastMessageText: undefined, …}into Onyx and clobber the user's LHN preview.Fix: each whisper component adds one
useOnyxsubscription without a selector to fetch the full report, and passes that wide value into the resolve action.ReportMentionWhisperContentandConfirmWhisperContentalso swap theiractionReport: OnyxEntry<Report>prop foractionReportID: string | undefined(the prop was only used for its ID anyway).MentionWhisperContentkeeps its existing prop shape — minimal diff, lowest regression surface. Only change is one addeduseOnyxline and three call-site swaps fromactionReporttoactionReportFull.Fixed Issues
$ #91394
PROPOSAL:
Tests
1. Chat — send & receive
2. Message edit — scroll-to-index
3. Expense report activity
4. Search — chat results
5. Whisper — user mention
@mentionsomeone not in the chat.6. Whisper — room mention
#mentiona room → tap Yes.7. Offline — general
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
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
1.mov
2.mov
3.mov
4.mov