perf: remove unnecessary props from ReportActionContextMenu (isChronosReport, isPinnedChat, isUnreadChat, isThreadReportParentAction)#89683
Conversation
Remove the isChronosReport prop from BaseReportActionContextMenu, PopoverReportActionContextMenu, and the showContextMenu() public API. Derive it inside BaseReportActionContextMenu using the already-imported chatIncludesChronosWithID(originalReportID) — the same call that was already used in openOverflowMenu for the overflow submenu case. Remove isChronos from openOverflowMenu's showContextMenu call since it was always chatIncludesChronosWithID(originalReportID), identical to the new derived value. Remove isChronosReport from MiniReportActionContextMenu and the showPopover call in PureReportActionItem. Co-authored-by: Cursor <cursoragent@cursor.com>
Remove the isPinnedChat prop from BaseReportActionContextMenu, PopoverReportActionContextMenu, and the showContextMenu() public API. Derive it inside BaseReportActionContextMenu as !!report?.isPinned, using the report object already subscribed to via useOnyx. Remove isPinnedChat from OptionRowPressable's showContextMenu call. Co-authored-by: Cursor <cursoragent@cursor.com>
Remove the isUnreadChat prop from BaseReportActionContextMenu, PopoverReportActionContextMenu, and the showContextMenu() public API. Derive it inside BaseReportActionContextMenu by comparing report.lastReadTime against report.lastVisibleActionCreated, using the report already subscribed to via useOnyx. Remove isUnreadChat from OptionRowPressable's showContextMenu call. Co-authored-by: Cursor <cursoragent@cursor.com>
Remove the isThreadReportParentAction prop from BaseReportActionContextMenu, PopoverReportActionContextMenu, and the showContextMenu() public API. Derive it inside BaseReportActionContextMenu by checking whether the reportAction's childReportID matches the current reportID — this is true exactly when we're viewing the parent action from within its thread report. Remove isThreadReportParentAction from MiniReportActionContextMenu and the showPopover call in PureReportActionItem. Remove it from openOverflowMenu's showContextMenu call since the overflow context menu will re-derive it internally from the same condition. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f259145ba6
ℹ️ 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".
| const isPinnedChat = !!report?.isPinned; | ||
| const isUnreadChat = !report?.lastReadTime || report.lastReadTime < (report.lastVisibleActionCreated ?? ''); | ||
| // True when this action is the parent of a thread and we're viewing from within that thread | ||
| const isThreadReportParentAction = !!reportAction?.childReportID && String(reportAction.childReportID) === reportID; |
There was a problem hiding this comment.
Preserve thread-parent context in ancestor menus
When the context menu is opened on the parent action shown at the top of a thread, ReportActionItemParentAction renders that row with report={ancestorReport} (the parent report) while the action's childReportID is the current thread report, so this comparison is false even though the row is explicitly a thread parent action. Before this change that boolean was passed through, but now the menu treats the thread header as a normal action, which can re-enable actions such as replying/opening the same thread and changes the join/leave thread options for that specific thread-header menu.
Useful? React with 👍 / 👎.
Explanation of Change
Removes 4 props that were unnecessarily threaded through the entire ReportActionContextMenu prop chain and derives them internally inside
BaseReportActionContextMenuusing Onyx data it already subscribes to. This also removes unnecessary state variables andsetStatecalls which trigger additional re-renders inPopoverReportActionContextMenu.This is an extraction from #83784.
Fixed Issues
(partial) #83774
Tests
isThreadReportParentActionderivation is correctOffline tests
N/A — context menus are UI-only and don't make network requests.
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
web.mov
web.mov