You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Decompose PureReportActionItem to isolate hooks per action type #87157
PureReportActionItem is a 2,200+ line monolith with 100+ if/else if branches. Every render evaluates the full chain and runs all top-level hooks (useOnyx, useMemo) regardless of which action type is actually being displayed.
Proposed fix
Extract groups of related branches into focused child components (PolicyChangeLogContent, ApprovalFlowContent, PaymentContent, etc.), then move action-type-specific hooks into those children so they only run when needed.
I'm trying to keep phases clean so it will be possible to prepare PRs commit by commit later.
First I want to check how much we can get from low-risk changes in component structure only with this strategy.
Phase 3 (ActionableWhisperContent): Extract 3 actionable whisper branches (fraud alert, join request, mention whisper) into a self-contained component with their own button logic (dd852e7f55d)
Phase 4 (ChatMessageContent): Extract the default chat message branch along with 3 useOnyx calls, 2 custom hooks, actionableItemButtons useMemo, moderation state, and 2 context provider useMemos (2a04dc707df)
I stopped refactor to get some measurements. Metric itself and profiler results sadly stays the same. There is noise in results so no winner so far. For sure its getting more readable with each step (8 new components from PureReportActionItem).
I noticed some consistency in Performance trace improvements when tested chat with ~90 items:
ReportActionItem: 240ms → 165ms (-31%, total time for all list items)
PureReportActionItem: 92ms → 66ms (-28%, total time for all list items)
-6 subscription per message (-12%)
-425 total onyx subscriptions
In progress (low risk):
Phase 6: Push cardList into self-subscribing CardBrokenConnectionContent
Phase 7: Push taskReport into TaskPreview
Phase 8: Push linkedReport + iouReportOfLinkedReport into TripRoomPreview
Phase 9: Push userBillingGracePeriodEnds into ChatMessageContent Extract ChatTransactionPreview
Phase 10: Extract ReimbursementQueuedContent — remove bankAccountList + missingPaymentMethod from per-item path and move it down to specific branch
Phase 11: Conditional useOnyx in ReportActionItemMessage for IOU branch
With phase 11 I managed to get some consistent improvement in span metric.
PureReportActionItem was reduced from ~2250 lines to ~1400.
Each comment message creates 14 less useOnyx subscriptions.
Update:
Phase 1 (unit tests): #87347 - ready for review
Phase 2 (basic split): I will prepare four small PRs, one for each new grouping component. I’ll keep this based on the unit test branch for now and mark it as a draft until the tests are merged.
I prepared another draft PR with the Phase 3 changes (the list above has been updated). It would be great if we could proceed with this one: #87347, as it provides a safe base for all changes (Phase 1 unit tests). I’m trying to keep the remaining changes separate from each other (at least so far)
Last one from original plan #88601 is ready for review. Tomorrow I plan to check if there is something more to move around after all this effort so far
Follow-up decompositions of PureReportActionItem to push subscriptions down into leaves, which removes 6 onyx subs from regular ADD COMMENT report action (22 -> 16).
reportMetadata → ApprovalFlowContent: useOnyx(REPORT_METADATA_<reportID>) only runs for SUBMITTED / APPROVED / FORWARDED actions.
personalPolicyID → MentionWhisperContent: useOnyx(PERSONAL_POLICY_ID) only runs when a mention whisper is rendered.
parentReport → ReimbursementQueuedContent + ReportActionItemContentCreated: useOnyx(REPORT_<parentReportID>) only runs in those branches.
childReport → 4 explain-path leaves: useOnyx(REPORT_<childReportID>) removed from PureReportActionItem and inlined into ModifiedExpenseContent, ApprovalFlowContent, MovedTransactionAction, UnreportedTransactionAction.
policy → IssueCardMessageContainer: new tiny container holds the useOnyx(POLICY_<policyID>) call and derives isPolicyAdmin. Five other leaves (ApprovalFlowContent, PaymentContent, PolicyChangeLogContent, JoinRequestContent, MentionWhisperContent) self-sub policy instead of receiving it as a prop.
WhisperBanner extracted: the "Only visible to …" banner and its computations (whisperedToPersonalDetails, displayNamesWithTooltips, isMultipleParticipant, isWhisperOnlyVisibleByUser, getWhisperDisplayNames, useMemoizedLazyExpensifyIcons(['Eye'])) live in WhisperBanner.tsx. Mounts only when isWhisper === true.
SearchActionHeader extracted: replaces the renderSearchHeader inline function with a self-gating component. Inner SearchActionHeaderContent (which holds useOnyx(CONCIERGE_REPORT_ID) and getChatListItemReportName) only mounts when isOnSearch === true.
Each mounted ReportActionItem for a plain ADDCOMMENT on inbox now drops the following Onyx subscriptions vs. before this work:
Subscription
Before
After
REPORT_METADATA_<reportID>
every cell
only ApprovalFlow rows
PERSONAL_POLICY_ID
every cell
only MentionWhisper rows
REPORT_<parentReportID>
every cell
only ReimbursementQueued / created-thread-parent rows
REPORT_<childReportID>
every cell
only inside 4 specialty leaves
POLICY_<policyID>
every cell
only inside 6 policy-consuming leaves
CONCIERGE_REPORT_ID
every cell
only on search
While #88600 and #88601 are in review, I will prepare new PRs based on that. I think I will split this round into 2-3 PRs to avoid such noise with too many sub-issues, also these are not so complex. Currently I hold all changes in single POC draft PR #89107
Mean from 30 messages in heavy account (exfy-perf account, web): 453.0 ms -> 438.7 ms (−3.2%)
With 4,4x CPU slowdown (mid-tier phone simulation): 2405.0 ms -> 2072.4 ms (-13.8%)
For 87 mounted list items totalSubscriptions drop (for whole app, but only comments in chat): 6689 -> 5921
Activity
LukasMod commentedon Apr 7, 2026
I'm trying to keep phases clean so it will be possible to prepare PRs commit by commit later.
First I want to check how much we can get from low-risk changes in component structure only with this strategy.
Done:
c564c511c1e)SimpleMessageContent, PaymentContent, PolicyChangeLogContent, ApprovalFlowContent(62e0b39961f)dd852e7f55d)2a04dc707df)4c923d0f4f8+570e13e2f87)Current results:
I stopped refactor to get some measurements. Metric itself and profiler results sadly stays the same. There is noise in results so no winner so far. For sure its getting more readable with each step (8 new components from PureReportActionItem).
I noticed some consistency in Performance trace improvements when tested chat with ~90 items:
In progress (low risk):
cardListinto self-subscribingCardBrokenConnectionContenttaskReportinto TaskPreviewlinkedReport+iouReportOfLinkedReportinto TripRoomPreviewLukasMod commentedon Apr 7, 2026
I finished phases 6-8 and 3 more ideas:
PushExtract ChatTransactionPreviewuserBillingGracePeriodEndsinto ChatMessageContentReimbursementQueuedContent— removebankAccountList+missingPaymentMethodfrom per-item path and move it down to specific branchWith phase 11 I managed to get some consistent improvement in span metric.
PureReportActionItem was reduced from ~2250 lines to ~1400.
Each comment message creates 14 less useOnyx subscriptions.
I will split main PR to small ones
LukasMod commentedon Apr 8, 2026
Update:
Phase 1 (unit tests): #87347 - ready for review
Phase 2 (basic split): I will prepare four small PRs, one for each new grouping component. I’ll keep this based on the unit test branch for now and mark it as a draft until the tests are merged.
Phase 3 (Whisper components): #87507 (-1 useOnyx from moving down useReportIsArchived)
cristipaval commentedon Apr 8, 2026
Thanks @LukasMod! Love the investigation and the detailed updates!
LukasMod commentedon Apr 10, 2026
I prepared another draft PR with the Phase 3 changes (the list above has been updated). It would be great if we could proceed with this one: #87347, as it provides a safe base for all changes (Phase 1 unit tests). I’m trying to keep the remaining changes separate from each other (at least so far)
cristipaval commentedon Apr 10, 2026
Thanks @LukasMod. #87347 has been merged
41 remaining items
LukasMod commentedon Apr 24, 2026
Phase 10 ready to review, Phase 11 almost ready (need to do some manual smoke tests and videos)
LukasMod commentedon Apr 27, 2026
Last one from original plan #88601 is ready for review. Tomorrow I plan to check if there is something more to move around after all this effort so far
LukasMod commentedon Apr 28, 2026
Follow-up decompositions of
PureReportActionItemto push subscriptions down into leaves, which removes 6 onyx subs from regular ADD COMMENT report action (22 -> 16).reportMetadata→ApprovalFlowContent:useOnyx(REPORT_METADATA_<reportID>)only runs for SUBMITTED / APPROVED / FORWARDED actions.personalPolicyID→MentionWhisperContent:useOnyx(PERSONAL_POLICY_ID)only runs when a mention whisper is rendered.parentReport→ReimbursementQueuedContent+ReportActionItemContentCreated:useOnyx(REPORT_<parentReportID>)only runs in those branches.childReport→ 4 explain-path leaves:useOnyx(REPORT_<childReportID>)removed fromPureReportActionItemand inlined intoModifiedExpenseContent,ApprovalFlowContent,MovedTransactionAction,UnreportedTransactionAction.policy→IssueCardMessageContainer: new tiny container holds theuseOnyx(POLICY_<policyID>)call and derivesisPolicyAdmin. Five other leaves (ApprovalFlowContent,PaymentContent,PolicyChangeLogContent,JoinRequestContent,MentionWhisperContent) self-subpolicyinstead of receiving it as a prop.WhisperBannerextracted: the "Only visible to …" banner and its computations (whisperedToPersonalDetails,displayNamesWithTooltips,isMultipleParticipant,isWhisperOnlyVisibleByUser,getWhisperDisplayNames,useMemoizedLazyExpensifyIcons(['Eye'])) live inWhisperBanner.tsx. Mounts only whenisWhisper === true.SearchActionHeaderextracted: replaces therenderSearchHeaderinline function with a self-gating component. InnerSearchActionHeaderContent(which holdsuseOnyx(CONCIERGE_REPORT_ID)andgetChatListItemReportName) only mounts whenisOnSearch === true.Each mounted
ReportActionItemfor a plain ADDCOMMENT on inbox now drops the following Onyx subscriptions vs. before this work:REPORT_METADATA_<reportID>PERSONAL_POLICY_IDREPORT_<parentReportID>REPORT_<childReportID>POLICY_<policyID>CONCIERGE_REPORT_IDWhile #88600 and #88601 are in review, I will prepare new PRs based on that. I think I will split this round into 2-3 PRs to avoid such noise with too many sub-issues, also these are not so complex. Currently I hold all changes in single POC draft PR #89107
Mean from 30 messages in heavy account (exfy-perf account, web): 453.0 ms -> 438.7 ms (−3.2%)
With 4,4x CPU slowdown (mid-tier phone simulation): 2405.0 ms -> 2072.4 ms (-13.8%)
For 87 mounted list items totalSubscriptions drop (for whole app, but only comments in chat): 6689 -> 5921
cristipaval commentedon Apr 29, 2026
Nice work on this round, @LukasMod! The -13.8% under CPU throttling and ~770 fewer subscriptions are solid numbers.
I created #89164 to track this next phase. Let's create subissues there for the phases of this new round.
cristipaval commentedon Apr 29, 2026
I'll close this issue when the last in review PRs are merged and deployed.
LukasMod commentedon Apr 29, 2026
Sure, I will update plan with current PRs for sub-issues there soon
melvin-bot commentedon May 4, 2026
@LukasMod Eep! 4 days overdue now. Issues have feelings too...
LukasMod commentedon May 5, 2026
All merged, waiting for last few to deploy
melvin-bot commentedon May 8, 2026
@LukasMod Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!