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
[$250] Extract action buttons from MoneyRequestReportPreviewContent #86111
changed the title [-]Extract action buttons from MoneyRequestReportPreviewContent[/-][+][$250] Extract action buttons from MoneyRequestReportPreviewContent[/+]on Mar 23, 2026
Summary: This issue tracks a performance optimization to extract action button logic (Submit, Approve, Pay, Export, View, Add Expense) from MoneyRequestReportPreviewContent into isolated components, reducing unnecessary re-renders of the entire preview (carousel, header, etc.) when only button-related Onyx data changes.
PR:#85949 by TMisiukiewicz implements this extraction.
Architecture of the Change
The PR introduces a router pattern:
ReportPreviewActionButton (router) — subscribes to Onyx data needed to determine which button to show via getReportPreviewAction(), then conditionally renders only the active button component
SubmitActionButton / ApproveActionButton / PayActionButton — self-contained components with their own Onyx subscriptions, only mounted when needed
Export, View, and Add Expense remain inline in the router (lightweight, no separate components needed)
Key benefit: The parent MoneyRequestReportPreviewContent sheds ~14 Onyx subscriptions. When button-specific data changes (e.g., bankAccountList, betas, introSelected), only the button subtree re-renders — the expensive FlashList carousel, header, and preview message are untouched.
The new SubmitActionButton adds an isDelegateAccessRestricted check before calling submitReport(). The original submitAction in the parent did not have this check — only Approve and Pay had it. This could block delegates from submitting reports. This may be an intentional bug fix, but it should be explicitly documented and tested.
This changes behavior for the approval hold path: previously, if both approve and pay were potentially available, non-reimbursable amounts could be excluded during approval. Now they're only excluded for the PAY action. This could change displayed amounts in the hold menu dialog for approval scenarios.
3. Loss of useMemo on getReportPreviewAction (Low-Medium concern)
The original parent wrapped reportPreviewAction in useMemo with a 17-item dependency array. The new router calls it directly in the render body without memoization. Since the router has ~15 Onyx subscriptions, any change triggers a fresh (unmemoized) call to getReportPreviewAction(), which does meaningful work (calls canSubmit, canApprove, canPay, canExport).
Three components independently call getReportTransactions(iouReportID) and filter by pending action: the router, PayActionButton, and SubmitActionButton. The parent already receives transactions as a prop — passing them through would avoid redundant work.
5. Hardcoded height value (Cosmetic)
ReportPreviewActionButton.tsx uses {height: 40} instead of variables.h40, breaking the convention of using the variables module for magic numbers.
Onyx Subscription Analysis
Location
Before
After
MoneyRequestReportPreviewContent
18 subscriptions
~4 subscriptions
ReportPreviewActionButton (router, always active)
N/A
~15 subscriptions
SubmitActionButton (only when SUBMIT active)
N/A
~7 subscriptions
ApproveActionButton (only when APPROVE active)
N/A
~8 subscriptions
PayActionButton (only when PAY active)
N/A
~13 subscriptions
The net subscription count increases slightly, but the key win is isolation: button subscriptions no longer trigger re-renders of the carousel, header, and preview message sections.
Detailed Investigation
Root Cause Analysis
MoneyRequestReportPreviewContent is a ~1113-line component with 17 useOnyx calls + 1 usePolicy call (18 total Onyx subscriptions). It renders:
Header (report name, status badge, expense count, carousel arrows)
Transaction Carousel (FlashList of transaction previews)
Action Footer (one of 6 action buttons + total amount)
Hold Menu Modal (conditional ProcessMoneyReportHoldMenu)
The problem: many Onyx subscriptions (e.g., BANK_ACCOUNT_LIST, BETAS, NVP_INTRO_SELECTED, COLLECTION.TRANSACTION_VIOLATIONS) are only needed by specific action buttons, but any change to them triggers a full re-render including the expensive FlashList carousel.
Evidence Chain
MoneyRequestReportPreviewContent.tsx:135-260 — 18 Onyx subscriptions in the parent, many button-specific
MoneyRequestReportPreviewContent.tsx:746-852 — All 6 button variants created on every render regardless of which is displayed
MoneyRequestReportPreviewContent.tsx:866-883 — Switch statement selects one button via getReportPreviewAction()
ReportPreviewActionUtils.ts:186-252 — Priority cascade determines active action (only ONE at a time)
The extraction moves button-specific subscriptions to child components, isolating re-renders to the button subtree
Relevant Code
App/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx — Main component being refactored
PR creates 4 new files: ReportPreviewActionButton.tsx, SubmitActionButton.tsx, ApproveActionButton.tsx, PayActionButton.tsx
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
changed the title [-][Due for payment 2026-04-07] [$250] Extract action buttons from MoneyRequestReportPreviewContent[/-][+][$250] Extract action buttons from MoneyRequestReportPreviewContent[/+]on May 6, 2026
Activity
melvin-bot commentedon Mar 23, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Krishna2323 (
External)[-]Extract action buttons from MoneyRequestReportPreviewContent[/-][+][$250] Extract action buttons from MoneyRequestReportPreviewContent[/+]melvin-bot commentedon Mar 23, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022036109715816720684
MelvinBot commentedon Mar 23, 2026
🔍 Issue Analysis
Summary: This issue tracks a performance optimization to extract action button logic (Submit, Approve, Pay, Export, View, Add Expense) from
MoneyRequestReportPreviewContentinto isolated components, reducing unnecessary re-renders of the entire preview (carousel, header, etc.) when only button-related Onyx data changes.PR: #85949 by
TMisiukiewiczimplements this extraction.Architecture of the Change
The PR introduces a router pattern:
ReportPreviewActionButton(router) — subscribes to Onyx data needed to determine which button to show viagetReportPreviewAction(), then conditionally renders only the active button componentSubmitActionButton/ApproveActionButton/PayActionButton— self-contained components with their own Onyx subscriptions, only mounted when neededKey benefit: The parent
MoneyRequestReportPreviewContentsheds ~14 Onyx subscriptions. When button-specific data changes (e.g.,bankAccountList,betas,introSelected), only the button subtree re-renders — the expensiveFlashListcarousel, header, and preview message are untouched.Potential Concerns Found
1. Undocumented behavioral change — delegate access check added to Submit (Medium concern)
The new
SubmitActionButtonadds anisDelegateAccessRestrictedcheck before callingsubmitReport(). The originalsubmitActionin the parent did not have this check — only Approve and Pay had it. This could block delegates from submitting reports. This may be an intentional bug fix, but it should be explicitly documented and tested.2.
getNonHeldAndFullAmountparameter semantics changed (Low-Medium concern)getNonHeldAndFullAmount(iouReport, shouldShowPayButton)whereshouldShowPayButton = isPaidAnimationRunning || canIOUBePaid || onlyShowPayElsewheregetNonHeldAndFullAmount(iouReport, requestType === CONST.IOU.REPORT_ACTION_TYPE.PAY)This changes behavior for the approval hold path: previously, if both approve and pay were potentially available, non-reimbursable amounts could be excluded during approval. Now they're only excluded for the PAY action. This could change displayed amounts in the hold menu dialog for approval scenarios.
3. Loss of
useMemoongetReportPreviewAction(Low-Medium concern)The original parent wrapped
reportPreviewActioninuseMemowith a 17-item dependency array. The new router calls it directly in the render body without memoization. Since the router has ~15 Onyx subscriptions, any change triggers a fresh (unmemoized) call togetReportPreviewAction(), which does meaningful work (callscanSubmit,canApprove,canPay,canExport).4. Redundant
getReportTransactionscalls (Low concern)Three components independently call
getReportTransactions(iouReportID)and filter by pending action: the router,PayActionButton, andSubmitActionButton. The parent already receivestransactionsas a prop — passing them through would avoid redundant work.5. Hardcoded height value (Cosmetic)
ReportPreviewActionButton.tsxuses{height: 40}instead ofvariables.h40, breaking the convention of using the variables module for magic numbers.Onyx Subscription Analysis
MoneyRequestReportPreviewContentReportPreviewActionButton(router, always active)SubmitActionButton(only when SUBMIT active)ApproveActionButton(only when APPROVE active)PayActionButton(only when PAY active)The net subscription count increases slightly, but the key win is isolation: button subscriptions no longer trigger re-renders of the carousel, header, and preview message sections.
Detailed Investigation
Root Cause Analysis
MoneyRequestReportPreviewContentis a ~1113-line component with 17useOnyxcalls + 1usePolicycall (18 total Onyx subscriptions). It renders:FlashListof transaction previews)ProcessMoneyReportHoldMenu)The problem: many Onyx subscriptions (e.g.,
BANK_ACCOUNT_LIST,BETAS,NVP_INTRO_SELECTED,COLLECTION.TRANSACTION_VIOLATIONS) are only needed by specific action buttons, but any change to them triggers a full re-render including the expensive FlashList carousel.Evidence Chain
MoneyRequestReportPreviewContent.tsx:135-260— 18 Onyx subscriptions in the parent, many button-specificMoneyRequestReportPreviewContent.tsx:746-852— All 6 button variants created on every render regardless of which is displayedMoneyRequestReportPreviewContent.tsx:866-883— Switch statement selects one button viagetReportPreviewAction()ReportPreviewActionUtils.ts:186-252— Priority cascade determines active action (only ONE at a time)Relevant Code
App/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx— Main component being refactoredApp/src/libs/ReportPreviewActionUtils.ts:186-252—getReportPreviewAction()priority logicReportPreviewActionButton.tsx,SubmitActionButton.tsx,ApproveActionButton.tsx,PayActionButton.tsxNext Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.melvin-bot commentedon Mar 26, 2026
@Krishna2323 Whoops! This issue is 2 days overdue. Let's get this updated quick!
14 remaining items
melvin-bot commentedon Apr 7, 2026
Payment Summary
Upwork Job
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Apr 8, 2026
Payment Summary
Contributor+: @Krishna2323 due $250 via NewDot
@Krishna2323 plz complete the BZ checklist and tag me in a post once you have. Thx
Krishna2323 commentedon Apr 8, 2026
@mallenexpensify checklist isn't required here, it was a perf PR.
Krishna2323 commentedon Apr 17, 2026
Requested in ND.
laurenreidexpensify commentedon Apr 20, 2026
@Krishna2323 $250 approved in New Expensify
dukenv0307 commentedon May 6, 2026
Coming from #88375, we need to pass transactions to confirmApproval as the reactive value
mallenexpensify commentedon May 6, 2026
@Krishna2323 👀 above please. Unsure of next steps.
[-][Due for payment 2026-04-07] [$250] Extract action buttons from MoneyRequestReportPreviewContent[/-][+][$250] Extract action buttons from MoneyRequestReportPreviewContent[/+]rlinoz commentedon May 7, 2026
I think we are good here, @dukenv0307 was just mentioning tha tthis had a bug and they fixed in the other issue.