Skip to content

[$250] Extract action buttons from MoneyRequestReportPreviewContent #86111

Closed

Description

@rlinoz

Placeholder issue for #85949

Issue OwnerCurrent Issue Owner: @Krishna2323
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022036109715816720684
  • Upwork Job ID: 2036109715816720684
  • Last Price Increase: 2026-03-23

Activity

  1. added
    Bug
    on Mar 23, 2026
  2. added
    External
    on Mar 23, 2026
  3. added
    Help Wanted
    on Mar 23, 2026
  4. melvin-bot commented on Mar 23, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @Krishna2323 (External)

  5. changed the title [-]Extract action buttons from MoneyRequestReportPreviewContent[/-] [+][$250] Extract action buttons from MoneyRequestReportPreviewContent[/+] on Mar 23, 2026
  6. melvin-bot commented on Mar 23, 2026

    @melvin-bot
  7. removed
    Help Wanted
    on Mar 23, 2026
  8. MelvinBot commented on Mar 23, 2026

    @MelvinBot
    Contributor

    🔍 Issue Analysis

    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:

    1. ReportPreviewActionButton (router) — subscribes to Onyx data needed to determine which button to show via getReportPreviewAction(), then conditionally renders only the active button component
    2. SubmitActionButton / ApproveActionButton / PayActionButton — self-contained components with their own Onyx subscriptions, only mounted when needed
    3. 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.

    Potential Concerns Found

    1. Undocumented behavioral change — delegate access check added to Submit (Medium concern)

    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.

    2. getNonHeldAndFullAmount parameter semantics changed (Low-Medium concern)

    • Original: getNonHeldAndFullAmount(iouReport, shouldShowPayButton) where shouldShowPayButton = isPaidAnimationRunning || canIOUBePaid || onlyShowPayElsewhere
    • New: getNonHeldAndFullAmount(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 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).

    4. Redundant getReportTransactions calls (Low concern)

    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:

    1. Header (report name, status badge, expense count, carousel arrows)
    2. Transaction Carousel (FlashList of transaction previews)
    3. Action Footer (one of 6 action buttons + total amount)
    4. 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
    • App/src/libs/ReportPreviewActionUtils.ts:186-252 — getReportPreviewAction() priority logic
    • 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.

  9. melvin-bot commented on Mar 26, 2026

    @melvin-bot

    @Krishna2323 Whoops! This issue is 2 days overdue. Let's get this updated quick!

  10. 14 remaining items

  11. melvin-bot commented on Apr 7, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants/2036109715816720684/hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  12. mallenexpensify commented on Apr 8, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @Krishna2323 due $250 via NewDot

    @Krishna2323 plz complete the BZ checklist and tag me in a post once you have. Thx

  13. Krishna2323 commented on Apr 8, 2026

    @Krishna2323
    Contributor

    @mallenexpensify checklist isn't required here, it was a perf PR.

  14. Krishna2323 commented on Apr 17, 2026

    @Krishna2323
    Contributor

    Requested in ND.

  15. laurenreidexpensify commented on Apr 20, 2026

    @laurenreidexpensify
    Contributor

    @Krishna2323 $250 approved in New Expensify

  16. dukenv0307 commented on May 6, 2026

    @dukenv0307
    Contributor

    Coming from #88375, we need to pass transactions to confirmApproval as the reactive value

  17. mallenexpensify commented on May 6, 2026

    @mallenexpensify
    Contributor

    @Krishna2323 👀 above please. Unsure of next steps.

  18. removed
    Awaiting Payment
    on May 6, 2026
  19. 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
  20. rlinoz commented on May 7, 2026

    @rlinoz
    ContributorAuthor

    I think we are good here, @dukenv0307 was just mentioning tha tthis had a bug and they fixed in the other issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions