Skip to content

Replace ProcessMoneyReportHoldMenu with useHoldMenuModal in SelectionToolbar and report preview - #104532

Merged
roryabraham merged 8 commits into
mainfrom
claude-replaceProcessMoneyReportHoldMenu
Oct 30, 2026
Merged

roryabraham merged 8 commits into
mainfrom
claude-replaceProcessMoneyReportHoldMenu

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

ProcessMoneyReportHoldMenu was an older, pay-only copy of the global HoldMenuModalWrapper. This PR moves its last two callers to useHoldMenuModal().showHoldMenu, as the report header already does, and deletes the old component.

  • Selection mode (useSelectionModeReportActions): both onHoldMenuOpen handlers now call showHoldMenu. They pass requestType, paymentType, methodID (VBBA only), the amounts, and onConfirm. onConfirm now runs the lifecycle callback that was dropped before (_onConfirm, for example marking the report as paid elsewhere), the same way the header dropdown does, then clears the selection. The local hold-menu state, handleHoldMenuClose, and handleHoldMenuConfirm are removed, along with the hold-menu block in SelectionToolbar.
  • Report preview (PayActionButton.confirmPayment): calls showHoldMenu directly. It computes the amounts with getNonHeldAndFullAmount, passes the report IDs (the wrapper reads the reports from Onyx), and passes onConfirm: startAnimation. ReportPreviewHoldMenu, the provider's holdMenu state, onHoldMenuOpen/onHoldMenuClose, and ReportPreviewHoldMenuContext are removed.
  • ActionHandledType imports now point at @hooks/useHoldMenuSubmit.
  • Both callers wait one animation frame on iOS before opening, matching MoneyReportHeaderModals.

Expected differences:

  1. The amounts are a snapshot taken when the menu opens. The header and ExpenseReportListItem already work this way.
  2. Selection mode's transactionCount now excludes expenses pending deletion. The hook only receives those transactions, and the count is only used in the "all expenses on hold" prompt.
  3. Confirming clears the selection and unmounts the toolbar. This is safer now because the global modal survives the unmount.

Tests: deleted ReportPreviewHoldMenuTest.tsx. Removed the provider-level hold-menu test from MoneyRequestReportPreview.test.tsx; that wiring no longer exists. Updated PayActionButtonTest.tsx and useSelectionModeReportActions.test.ts to assert the showHoldMenu calls, including VBBA methodID forwarding and the forwarded lifecycle onConfirm.

AI checks run locally: npm run typecheck passed. ESLint on all changed files passed. react-compiler-compliance-check check <changed files> passed. oxfmt was applied. jest --findRelatedTests on the changed source files passed: 23 suites, 495 tests. spell-changed could not run because git merge-base failed in the shallow clone. An automated web run of the Tests steps passed the report preview and selection mode pay flows (screenshots under MacOS: Chrome / Safari). Other platforms are still untested.

Fixed Issues

$ #102977
PROPOSAL:

Tests

Setup (one workspace admin account is enough)

  1. Create a workspace. In Workflows, turn on Add approvals (you are the approver) and Make or track payments (pay outside Expensify / Mark as paid).
  2. In the workspace chat, create two manual expenses ($10 and $20) on the same report, then submit the report.
  3. Open the report, open the $20 expense, and hold it with any reason.
  4. Go back to Workflows and turn off Add approvals. The submitted report now shows Pay.

Report preview

  1. In the workspace chat, click Pay on the report preview and choose Mark as paid.
  2. Verify the hold menu opens with Pay only $10.00 and Pay $30.00.
  3. Click Pay only $10.00.
  4. Verify the modal closes, the report shows paid $10.00 elsewhere, and the held $20 expense moves to a new report.

Selection mode

  1. Repeat steps 2-4 to get a fresh report with a $10 expense and a held $20 expense.
  2. Open the report and select both expenses with the checkboxes (long-press on mobile).
  3. Click Pay in the selection toolbar and choose Mark as paid.
  4. Verify the hold menu opens.
  5. Click Pay $30.00.
  6. Verify the modal closes, the selection clears, and the report shows Paid with a $30.00 total.

Dismiss

  1. Repeat steps 9-11, then dismiss the hold menu without choosing an option.
  2. Verify nothing is paid and the report still shows Pay.
  • Verify that no errors appear in the JS console

Offline tests

  1. Complete Tests setup steps 1-4 while online.
  2. Go offline.
  3. Repeat Tests steps 5-8.
  4. Verify the hold menu opens and the report shows paid $10.00 right away, with the held $20 expense on a separate report.
  5. Go back online.
  6. Verify the report stays paid and no errors appear.

QA Steps

Same as Tests.

On iOS native, also verify the hold menu opens right after you tap Pay in both the report preview and selection mode, with no stuck or frozen screen.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Tested on web (Chrome) by MelvinBot. Report preview: Pay → Mark as paid opens the hold menu; Pay only pays $10 and moves the held expense to a new report.

Hold menu from report preview with Pay only and Pay full options Paid 10 dollar report and split-off held report

Selection mode: Pay in the selection toolbar → Mark as paid opens the hold menu; Pay $30.00 pays the full report and clears the selection.

Hold menu from selection mode Report paid for full 30 dollars after selection mode

… the global modal

Co-authored-by: Yauheni Horbach <ZhenjaHorbach@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team October 21, 2026 06:56
@melvin-bot melvin-bot Bot added Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web labels Oct 21, 2026
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I created this PR from an upstream branch since I don't have push access to your fork.

To take ownership of this branch and be able to push updates, run:

git remote add upstream https://github.com/Expensify/App.git
git fetch upstream claude-replaceProcessMoneyReportHoldMenu
git checkout -b claude-replaceProcessMoneyReportHoldMenu upstream/claude-replaceProcessMoneyReportHoldMenu
git push -u origin claude-replaceProcessMoneyReportHoldMenu

Then you can close this PR and open a new one from your fork.

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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.

Files with missing lines Coverage Δ
.../MoneyRequestReportView/SelectionToolbar/index.tsx 89.18% <ø> (-0.62%) ⬇️
...estReportPreview/MoneyRequestReportPreviewBody.tsx 94.44% <ø> (ø)
...tReportPreview/MoneyRequestReportPreviewContext.ts 86.95% <ø> (+0.74%) ⬆️
...eportPreview/MoneyRequestReportPreviewProvider.tsx 97.35% <100.00%> (-0.09%) ⬇️
src/hooks/useSelectionModePayment.ts 83.93% <ø> (ø)
src/hooks/useSelectionModeReportActions.ts 93.04% <100.00%> (+5.64%) ⬆️
src/libs/HoldMenuUtils.ts 100.00% <100.00%> (ø)
src/components/MoneyReportHeaderModalsContext.tsx 20.00% <0.00%> (ø)
...Item/MoneyRequestReportPreview/PayActionButton.tsx 97.08% <91.66%> (-0.77%) ⬇️
src/components/MoneyReportHeaderModals.tsx 0.00% <0.00%> (ø)
... and 17 files with indirect coverage changes

@MelvinBot

MelvinBot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Android test steps verification results: ❌ fail

None of the six test cases ran, so this result says nothing about the PR's code. The setup never produced a payable report that still had a held expense, and then the app froze on an unrelated "Create expense" action. A Metro restart did not fix the freeze.
System notification shade still opens, so the device stayed responsive

Step Status
Report preview: Pay on a report with held expenses opens the hold menu (pay only or pay full amount)Not reached. The tester held an expense while the report was Outstanding, and it stayed next to a non-held expense. Approving the full amount cleared the hold. "Approve only" moved the held expense to its own report. Holding while in Draft split it out on submit. With approvals off, the report closed on submit, and you can't hold expenses on a closed report.
Outstanding report with one non-held and one held expense
❌
Report preview: "Pay only" pays the non-held amount and leaves the held expense unpaidNot reached. No report met the setup conditions.
❌
Report preview or report view: "Pay full amount" pays the full amountNot reached. No report met the setup conditions.
❌
Selection mode: selecting expenses including a held one and tapping Pay opens the hold menuNot attempted. The app froze before this step.
❌
Selection mode: confirming closes the modal, pays as chosen, and clears the selectionNot attempted. The app froze before this step.
❌
No red-box errors or crashes during these flowsNo red box appeared. The app stopped responding to taps after the tester opened the chat "+" menu and chose "Create expense." This happened outside the pay and hold flows. The device itself stayed responsive. Metro logged no JS errors.
App frozen on the Create expense quick-action sheet
System notification shade still opens, so the device stayed responsive
❌

The PR's Tests section is still a placeholder, so I used the acceptance criteria from [Batch 3] Replace ProcessMoneyReportHoldMenu with useHoldMenuModal in SelectionToolbar and report preview (2 modals). To get a real result, add steps to the Tests section that produce a payable report with a held expense. For example, an IOU between two accounts where the payer holds one expense. Then ask me again.


view run · view recording

@MelvinBot

Copy link
Copy Markdown
Contributor Author

⏱️ Ran out of time before I could finish. This usually means the task was too complex or I got stuck exploring. Please try again with a more specific request or post in #melvinbot-ai.

Run details

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@MelvinBot
Complete the author checklist and add test cases

@MelvinBot

MelvinBot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 Web test steps verification results: ⚠️ partial

The hold menu now opens from both the report preview and the selection toolbar, and both pay flows finish. In selection mode, "Pay only" showed $0.00 instead of $10.00, and console errors could not be captured on web.
Report paid for full 30 dollars after selection mode

Step Status
Report preview: Pay → Mark as paid opens the hold menu with Pay only $10.00 and Pay $30.00Both options appeared with the right amounts.
Report preview showing Pay buttonHold menu from report preview with Pay only and Pay full options
✅
Pay only closes the modal, pays $10.00, and moves the held $20 expense off the paid reportThe report shows "paid $10.00 elsewhere". The held expense moved to a new report.
Paid 10 dollar report and split-off held reportPaid report with only the non-held expense
✅
Selection mode: select both expenses, Pay → Mark as paid opens the hold menuThe hold menu opened. Both the toolbar button and the "Pay only" option showed $0.00 instead of $10.00. This PR moved the amount math without changing it, and the toolbar button amount comes from code this PR doesn't touch. So the $0.00 likely already happens on main. Please confirm.
Selection toolbar with Pay actionHold menu from selection mode
⚠️
Pay $30.00 closes the modal, clears the selection, and marks the report paidThe report shows Paid with a $30.00 total.
Report paid for full 30 dollars after selection mode
✅
No JS console errorsNo error toasts or crashes appeared. The web tester can't read console logs, so this isn't confirmed.
⚠️

PR body updated:

  • I added Tests (setup, report preview, selection mode, dismiss), Offline tests, and QA steps. A single workspace admin account can run them: submit with approvals on, hold an expense, then turn approvals off so Pay appears.
  • I checked the checklist items that are done (linked issue, test steps, unit tests, MacOS: Chrome) and the items that don't apply (no copy, assets, UI, markdown, or Storybook changes). I added the web screenshots under MacOS: Chrome / Safari.
  • You still need to test offline, with a High Traffic account, on Android and iOS, and with deeplinks. You also need to check the JS console and test the other affected components.

view run · view recording

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@MelvinBot
Fix conflicts and open the PR

…MoneyReportHoldMenu

Co-authored-by: Yauheni Horbach <ZhenjaHorbach@users.noreply.github.com>

# Conflicts:
#	src/components/MoneyRequestReportView/SelectionToolbar/index.tsx
@MelvinBot
MelvinBot marked this pull request as ready for review October 22, 2026 15:54
@MelvinBot
MelvinBot requested a review from a team as a code owner October 22, 2026 15:54
@melvin-bot
melvin-bot Bot requested review from ZhenjaHorbach and removed request for a team October 22, 2026 15:54
@melvin-bot

melvin-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

@ZhenjaHorbach 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]

@melvin-bot
melvin-bot Bot requested review from flaviadefaria and removed request for a team October 22, 2026 15:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T15:59:43.634739Z c8158a6 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I merged main into this branch, resolved the conflict, and marked the PR ready for review. GitHub now shows it as mergeable. It still needs reviews and passing checks.

Conflict details

The only conflict was in SelectionToolbar/index.tsx. main replaced the inline HoldOrRejectEducationalModal with the useHoldRejectEducationalModal hook. This PR removed the inline ProcessMoneyReportHoldMenu. I removed both blocks.

Checks I ran after the merge:

  • npm run typecheck passed.
  • npm run lint passed on the changed files.
  • The React Compiler compliance check passed.
  • Jest passed: PayActionButtonTest, useSelectionModeReportActions.test, and MoneyRequestReportPreview.test (79 tests).

view run


const formattedAmount = getTotalAmountForIOUReportPreviewButton(iouReport, policy, reportPreviewAction, transactions, convertToDisplayString);

// Only the pay flow opens this menu; approve surfaces its partial/full choice in the approve dropdown instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-3 (docs)

This new openHoldMenu helper duplicates logic that now lives in three places: here, in useSelectionModeReportActions.ts, and in MoneyReportHeaderModals.tsx. All three compute hasOnlyHeldExpenses / getNonHeldAndFullAmount, assemble the same showHoldMenu({... nonHeldAmount, fullAmount, hasNonHeldExpenses, transactionCount ...}) payload, and then defer the open by one frame on iOS with the identical if (getPlatform() === CONST.PLATFORM.IOS) { requestAnimationFrame(...) } block. This is a DRY violation that will drift as the hold-menu payload evolves.

Extract the shared payload assembly and the iOS deferral into a single reusable helper (for example a small function or an addition to useHoldMenuModal) and call it from all three sites. At minimum, factor the verbatim iOS deferral block into a shared helper so the requestAnimationFrame timing logic exists in one place:

// e.g. src/libs/runAfterTouchFrame.ts
function openAfterTouchFrame(open: () => void) {
    if (getPlatform() === CONST.PLATFORM.IOS) {
        requestAnimationFrame(open);
        return;
    }
    open();
}

Reviewed at: c8158a6 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3265ee6. I added src/libs/HoldMenuUtils.ts with two helpers:

  • getHoldMenuAmounts builds nonHeldAmount, fullAmount, hasNonHeldExpenses, and transactionCount.
  • openAfterTouchFrame holds the iOS one-frame deferral. It returns a promise, so MoneyReportHeaderModals keeps its Promise<void> contract.

All three callers now use them: PayActionButton, useSelectionModeReportActions, and MoneyReportHeaderModals. Each caller passes only what differs: the IDs, the payment fields, and onConfirm. tests/unit/HoldMenuUtilsTest.ts covers both helpers.


view run

const {nonHeldAmount, fullAmount, hasValidNonHeldAmount} = getNonHeldAndFullAmount(report, shouldShowPayButton, transactions, convertToDisplayString);
const hasOnlyHeldExpenses = hasOnlyHeldExpensesReportUtils(transactions);

const openHoldMenu = (requestType: ActionHandledType, paymentType?: PaymentMethodType, methodID?: number, onConfirm?: () => void) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-3 (docs)

This openHoldMenu helper duplicates the one added to PayActionButton.tsx (and the equivalent already in MoneyReportHeaderModals.tsx): the same showHoldMenu({... nonHeldAmount, fullAmount, hasNonHeldExpenses, transactionCount ...}) payload assembly and the same if (getPlatform() === CONST.PLATFORM.IOS) { requestAnimationFrame(() => open()); return; } iOS deferral. Keeping three near-identical copies means any change to the hold-menu contract or the deferral timing must be applied in multiple files.

Consolidate the shared payload building and the iOS deferral into a single reusable helper (or fold it into useHoldMenuModal.showHoldMenu) and have each caller pass only the data that actually differs (e.g. the selection-mode onConfirm that clears the selection).


Reviewed at: c8158a6 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3265ee6. This hook now calls the shared getHoldMenuAmounts and openAfterTouchFrame helpers from src/libs/HoldMenuUtils.ts. PayActionButton and MoneyReportHeaderModals call them too. The hook passes only its own data: the VBBA-only methodID and the onConfirm that clears the selection.


view run

@@ -74,14 +85,45 @@ function PayActionButton() {

const formattedAmount = getTotalAmountForIOUReportPreviewButton(iouReport, policy, reportPreviewAction, transactions, convertToDisplayString);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-15 (docs)

This comment joins two independent sentences with a semicolon, which the plain-comment-style rule calls out. Split it into two sentences:

// Only the pay flow opens this menu. Approve surfaces its partial/full choice in the approve dropdown instead.

Reviewed at: c8158a6 | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3265ee6. I split the comment into two sentences.


view run

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@MelvinBot
Fix comments

Co-authored-by: Yauheni Horbach <ZhenjaHorbach@users.noreply.github.com>
@MelvinBot
MelvinBot requested a review from a team as a code owner October 23, 2026 09:58
@melvin-bot
melvin-bot Bot requested a review from roryabraham October 23, 2026 09:58
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I fixed the merge conflict by merging main into this branch. The fix is in commit 6335edd.

Conflict: MoneyRequestReportPreviewProvider.tsx was the only file with a conflict. main removed useCallback from onHoldMenuOpen and onHoldMenuClose, but this PR deletes both callbacks. I kept the PR's version, so both callbacks stay removed.

Verification
  • I checked every file that both this PR and main changed (MoneyReportHeaderModals.tsx, PayActionButton.tsx, useSelectionModePayment.ts). main's changes there (the PDF modal hook and the Wise beta flag) merged cleanly alongside this PR's changes.
  • No code on main uses the removed ReportPreviewHoldMenuContext, ProcessMoneyReportHoldMenu, or ReportPreviewHoldMenu.
  • tests/unit/HoldMenuUtilsTest.ts passes locally.
  • I couldn't run the full typecheck, ESLint, or the other Jest suites in my environment because of local tooling limits, not the code. CI will run them on the new commit.

@MelvinBot

Copy link
Copy Markdown
Contributor Author

⚠️ MelvinBot CI Fix Loop Detected

MelvinBot has made 5 consecutive commits trying to fix CI failures. Automatic CI fix dispatches are now paused for this PR.

Next steps: A human should review the recent commits and resolve the conflicting CI errors manually.

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@MelvinBot
Add these changes

diff --git a/src/components/MoneyReportHeaderModals.tsx b/src/components/MoneyReportHeaderModals.tsx
index fe60e0ce2774..a8c50f4dee0c 100644
--- a/src/components/MoneyReportHeaderModals.tsx
+++ b/src/components/MoneyReportHeaderModals.tsx
@@ -8,7 +8,7 @@ import useReportIsArchived from '@hooks/useReportIsArchived';
 import useTransactionsAndViolationsForReport from '@hooks/useTransactionsAndViolationsForReport';
 
 import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
-import {getHoldMenuAmounts, openAfterTouchFrame} from '@libs/HoldMenuUtils';
+import {getHoldMenuAmounts} from '@libs/HoldMenuUtils';
 import {canIOUBePaid as canIOUBePaidAction} from '@libs/ReportUtils';
 
 import ONYXKEYS from '@src/ONYXKEYS';
@@ -68,8 +68,9 @@ function MoneyReportHeaderModalsContent({reportID, children}: MoneyReportHeaderM
     const {showOfflineModal, showDownloadErrorModal} = useAlertModals();
     const {openHoldEducational, openRejectModal} = useMoneyReportHeaderEducationalModals(moneyRequestReport?.reportID);
 
-    const openHoldMenu = ({requestType, paymentType, methodID, onConfirm}: HoldMenuParams): Promise<void> =>
-        openAfterTouchFrame(() =>
+    // Wait one frame so the current touch animation finishes before the modal opens
+    const openHoldMenu = ({requestType, paymentType, methodID, onConfirm}: HoldMenuParams) => {
+        requestAnimationFrame(() => {
             showHoldMenu({
                 reportID: moneyRequestReport?.reportID,
                 chatReportID: chatReport?.reportID,
@@ -78,8 +79,9 @@ function MoneyReportHeaderModalsContent({reportID, children}: MoneyReportHeaderM
                 methodID,
                 ...getHoldMenuAmounts(moneyRequestReport, shouldShowPayButton, transactions, convertToDisplayString),
                 onConfirm,
-            }),
-        ).then(() => {});
+            });
+        });
+    };
 
     const contextValue = {
         openHoldMenu,
diff --git a/src/components/MoneyReportHeaderModalsContext.tsx b/src/components/MoneyReportHeaderModalsContext.tsx
index 417bbf7a7f53..f16a53ed444b 100644
--- a/src/components/MoneyReportHeaderModalsContext.tsx
+++ b/src/components/MoneyReportHeaderModalsContext.tsx
@@ -13,7 +13,7 @@ type HoldMenuParams = {
 };
 
 type MoneyReportHeaderModalsContextValue = {
-    openHoldMenu: (params: HoldMenuParams) => Promise<void>;
+    openHoldMenu: (params: HoldMenuParams) => void;
     openPDFDownload: (options?: {onCancel?: () => void}) => void;
     openHoldEducational: () => void;
     openRejectModal: (action: RejectModalAction) => void;
@@ -22,7 +22,7 @@ type MoneyReportHeaderModalsContextValue = {
 };
 
 const defaultValue: MoneyReportHeaderModalsContextValue = {
-    openHoldMenu: () => Promise.resolve(),
+    openHoldMenu: () => {},
     openPDFDownload: () => {},
     openHoldEducational: () => {},
     openRejectModal: () => {},
diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/PayActionButton.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/PayActionButton.tsx
index 40f27b38180a..e32c665c3bd2 100644
--- a/src/components/ReportActionItem/MoneyRequestReportPreview/PayActionButton.tsx
+++ b/src/components/ReportActionItem/MoneyRequestReportPreview/PayActionButton.tsx
@@ -16,7 +16,7 @@ import usePermissions from '@hooks/usePermissions';
 import usePolicy from '@hooks/usePolicy';
 
 import {generateDefaultWorkspaceName} from '@libs/actions/Policy/Policy';
-import {getHoldMenuAmounts, openAfterTouchFrame} from '@libs/HoldMenuUtils';
+import {getHoldMenuAmounts} from '@libs/HoldMenuUtils';
 import {getTotalAmountForIOUReportPreviewButton} from '@libs/MoneyRequestReportUtils';
 import {isTrackOnboardingChoice} from '@libs/OnboardingUtils';
 import {hasDynamicExternalWorkflow} from '@libs/PolicyUtils';
@@ -83,7 +83,8 @@ function PayActionButton() {
         if (!iouReport) {
             return;
         }
-        openAfterTouchFrame(() =>
+        // Wait one frame so the current touch animation finishes before the modal opens
+        requestAnimationFrame(() => {
             showHoldMenu({
                 reportID: iouReportID,
                 chatReportID,
@@ -91,8 +92,8 @@ function PayActionButton() {
                 methodID,
                 ...getHoldMenuAmounts(iouReport, shouldShowPayButton, transactions, convertToDisplayString),
                 onConfirm: startAnimation,
-            }),
-        );
+            });
+        });
     };
 
     const confirmPayment = ({paymentType: type, payAsBusiness, methodID, paymentMethod}: PaymentActionParams) => {
diff --git a/src/hooks/useSelectionModeReportActions.ts b/src/hooks/useSelectionModeReportActions.ts
index eb6aa3022346..6c0ef80a6e49 100644
--- a/src/hooks/useSelectionModeReportActions.ts
+++ b/src/hooks/useSelectionModeReportActions.ts
@@ -3,7 +3,7 @@ import type {PopoverMenuItem} from '@components/PopoverMenu';
 import {useSearchSelectionActions} from '@components/Search/SearchContext';
 
 import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
-import {getHoldMenuAmounts, openAfterTouchFrame} from '@libs/HoldMenuUtils';
+import {getHoldMenuAmounts} from '@libs/HoldMenuUtils';
 import {getTotalAmountForIOUReportPreviewButton, isEveryReportTransactionSelected} from '@libs/MoneyRequestReportUtils';
 import TransitionTracker from '@libs/Navigation/TransitionTracker';
 import type {KYCFlowEvent, TriggerKYCFlow} from '@libs/PaymentUtils';
@@ -109,7 +109,8 @@ function useSelectionModeReportActions({
     const totalAmount = getTotalAmountForIOUReportPreviewButton(report, policy, CONST.REPORT.PRIMARY_ACTIONS.PAY, nonPendingDeleteTransactions, convertToDisplayString);
 
     const openHoldMenu = (requestType: ActionHandledType, paymentType?: PaymentMethodType, methodID?: number, onConfirm?: () => void) => {
-        openAfterTouchFrame(() =>
+        // Wait one frame so the current touch animation finishes before the modal opens
+        requestAnimationFrame(() => {
             showHoldMenu({
                 reportID: report?.reportID,
                 chatReportID: chatReport?.reportID,
@@ -122,8 +123,8 @@ function useSelectionModeReportActions({
                     clearSelectedTransactions(true);
                     turnOffMobileSelectionMode();
                 },
-            }),
-        );
+            });
+        });
     };
 
     // Submit/approve via shared useLifecycleActions (no animations on mobile, skipAnimation=true)
diff --git a/src/libs/HoldMenuUtils.ts b/src/libs/HoldMenuUtils.ts
index 556b34ec0d53..b53cdad29ebd 100644
--- a/src/libs/HoldMenuUtils.ts
+++ b/src/libs/HoldMenuUtils.ts
@@ -1,11 +1,9 @@
 import type {CurrencyListActionsContextType} from '@hooks/useCurrencyList';
 
-import CONST from '@src/CONST';
 import type {Report, Transaction} from '@src/types/onyx';
 
 import type {OnyxEntry} from 'react-native-onyx';
 
-import getPlatform from './getPlatform';
 import {getNonHeldAndFullAmount, hasOnlyHeldExpenses} from './ReportUtils';
 
 type HoldMenuAmounts = {
@@ -32,17 +30,4 @@ function getHoldMenuAmounts(
     };
 }
 
-/** Opens a modal. On iOS, it waits one frame first so the current touch animation finishes before the modal opens. */
-function openAfterTouchFrame<T>(open: () => T | PromiseLike<T>): Promise<T> {
-    if (getPlatform() === CONST.PLATFORM.IOS) {
-        return new Promise((resolve) => {
-            requestAnimationFrame(() => {
-                resolve(open());
-            });
-        });
-    }
-
-    return Promise.resolve(open());
-}
-
-export {getHoldMenuAmounts, openAfterTouchFrame};
+export {getHoldMenuAmounts};
diff --git a/tests/ui/components/PayActionButtonTest.tsx b/tests/ui/components/PayActionButtonTest.tsx
index ea419515ce18..487b8549c9af 100644
--- a/tests/ui/components/PayActionButtonTest.tsx
+++ b/tests/ui/components/PayActionButtonTest.tsx
@@ -127,8 +127,11 @@ jest.mock('@hooks/useOnyx', () => jest.fn());
 
 const mockShowHoldMenu = jest.fn();
 jest.mock('@hooks/useHoldMenuModal', () => ({__esModule: true, default: jest.fn(() => ({showHoldMenu: mockShowHoldMenu}))}));
-// Jest runs as iOS, where the hold menu waits one animation frame; use web so it opens synchronously.
-jest.mock('@libs/getPlatform', () => ({__esModule: true, default: jest.fn(() => 'web')}));
+// The hold menu waits one animation frame before opening; run the frame right away so it opens synchronously.
+jest.spyOn(global, 'requestAnimationFrame').mockImplementation((callback) => {
+    callback(0);
+    return 0;
+});
 
 jest.mock('@components/DelegateNoAccessModalProvider', () => ({
     __esModule: true,
diff --git a/tests/unit/HoldMenuUtilsTest.ts b/tests/unit/HoldMenuUtilsTest.ts
index de6f48a5610b..2d5085bd2598 100644
--- a/tests/unit/HoldMenuUtilsTest.ts
+++ b/tests/unit/HoldMenuUtilsTest.ts
@@ -1,23 +1,14 @@
-import getPlatform from '@libs/getPlatform';
-import {getHoldMenuAmounts, openAfterTouchFrame} from '@libs/HoldMenuUtils';
+import {getHoldMenuAmounts} from '@libs/HoldMenuUtils';
 import {getNonHeldAndFullAmount, hasOnlyHeldExpenses} from '@libs/ReportUtils';
 
-import CONST from '@src/CONST';
-
 import {createRandomReport} from '../utils/collections/reports';
 import createRandomTransaction from '../utils/collections/transaction';
 
-jest.mock('@libs/getPlatform', () => ({
-    __esModule: true,
-    default: jest.fn(() => 'web'),
-}));
-
 jest.mock('@libs/ReportUtils', () => ({
     getNonHeldAndFullAmount: jest.fn(),
     hasOnlyHeldExpenses: jest.fn(),
 }));
 
-const mockGetPlatform = jest.mocked(getPlatform);
 const mockGetNonHeldAndFullAmount = jest.mocked(getNonHeldAndFullAmount);
 const mockHasOnlyHeldExpenses = jest.mocked(hasOnlyHeldExpenses);
 
@@ -28,7 +19,6 @@ const convertToDisplayString = jest.fn();
 describe('HoldMenuUtils', () => {
     beforeEach(() => {
         jest.clearAllMocks();
-        mockGetPlatform.mockReturnValue(CONST.PLATFORM.WEB);
     });
 
     describe('getHoldMenuAmounts', () => {
@@ -70,42 +60,4 @@ describe('HoldMenuUtils', () => {
             expect(amounts.hasNonHeldExpenses).toBe(true);
         });
     });
-
-    describe('openAfterTouchFrame', () => {
-        it('opens right away on platforms other than iOS', async () => {
-            // Given a platform other than iOS
-            mockGetPlatform.mockReturnValue(CONST.PLATFORM.WEB);
-            const open = jest.fn(() => 'opened');
-
-            // When the modal is opened
-            const result = openAfterTouchFrame(open);
-
-            // Then it opens synchronously and the promise resolves with the open result
-            expect(open).toHaveBeenCalledTimes(1);
-            await expect(result).resolves.toBe('opened');
-        });
-
-        it('waits one animation frame on iOS', async () => {
-            // Given iOS, where the touch animation must finish before a modal opens
-            mockGetPlatform.mockReturnValue(CONST.PLATFORM.IOS);
-            let runFrame: FrameRequestCallback | undefined;
-            const requestAnimationFrameSpy = jest.spyOn(global, 'requestAnimationFrame').mockImplementation((callback) => {
-                runFrame = callback;
-                return 0;
-            });
-            const open = jest.fn(() => Promise.resolve('closed'));
-
-            // When the modal is opened
-            const result = openAfterTouchFrame(open);
-
-            // Then it does not open until the next frame runs
-            expect(open).not.toHaveBeenCalled();
-            runFrame?.(0);
-            expect(open).toHaveBeenCalledTimes(1);
-
-            // And the promise follows the promise that open returns
-            await expect(result).resolves.toBe('closed');
-            requestAnimationFrameSpy.mockRestore();
-        });
-    });
 });
diff --git a/tests/unit/hooks/useSelectionModeReportActions.test.ts b/tests/unit/hooks/useSelectionModeReportActions.test.ts
index d3f436f69a90..bd2af7e5ab61 100644
--- a/tests/unit/hooks/useSelectionModeReportActions.test.ts
+++ b/tests/unit/hooks/useSelectionModeReportActions.test.ts
@@ -175,11 +175,11 @@ jest.mock('@hooks/useHoldMenuModal', () => ({
     default: jest.fn(() => ({showHoldMenu: mockShowHoldMenu})),
 }));
 
-// Jest runs as iOS, where the hold menu waits one animation frame; use web so it opens synchronously.
-jest.mock('@libs/getPlatform', () => ({
-    __esModule: true,
-    default: jest.fn(() => 'web'),
-}));
+// The hold menu waits one animation frame before opening; run the frame right away so it opens synchronously.
+jest.spyOn(global, 'requestAnimationFrame').mockImplementation((callback) => {
+    callback(0);
+    return 0;
+});
 
 jest.mock('@hooks/useLazyAsset', () => ({
     __esModule: true,

@MelvinBot

Copy link
Copy Markdown
Contributor Author

I added your changes in commit 2b1ab3d. The hold menu now waits one frame with requestAnimationFrame on every platform, and openAfterTouchFrame is gone.

Two files no longer matched your diff after the earlier main merge, so I edited them by hand:

  • MoneyReportHeaderModals.tsx: I applied the hold-menu change and kept main's useReportPDFDownloadModal-based openPDFDownload.
  • MoneyReportHeaderModalsContext.tsx: I changed only openHoldMenu to return void. openPDFDownload keeps main's newer signature, () => Promise<ModalStateChangePayload | undefined>. Your diff would have reverted it to the old one.
Verification
  • These Jest suites pass (42 tests): HoldMenuUtilsTest, PayActionButtonTest, and useSelectionModeReportActions.test.
  • No code still uses openAfterTouchFrame or relies on openHoldMenu returning a promise. In MoneyReportHeaderSelectionDropdown.tsx, the openHoldMenuAsync wrapper still compiles, but its name is now misleading. Tell me if you want it removed.
  • I couldn't run typecheck or ESLint to completion here. Both hit the sandbox's time and memory limits, so CI will run them.

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

Okay
Looks like the latest changes didn't break anything
LGTM!

@melvin-bot
melvin-bot Bot requested a review from roryabraham October 28, 2026 10:43
@roryabraham

Copy link
Copy Markdown
Contributor

conflicts

roryabraham
roryabraham previously approved these changes Oct 28, 2026
@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@MelvinBot
Fix conflicts

…MoneyReportHoldMenu

Co-authored-by: Yauheni Horbach <ZhenjaHorbach@users.noreply.github.com>

# Conflicts:
#	src/components/ProcessMoneyReportHoldMenu.tsx
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I fixed the conflicts by merging main into this branch and pushed the result in 71ca254.

There was one conflict. main edited ProcessMoneyReportHoldMenu.tsx, which this PR deletes. I kept the deletion.

Why it was safe to keep the deletion

On main, the hold menu now shows the "Pay only" option only when nonHeldAmount is defined. It no longer checks hasNonHeldExpenses. main made the same change to HoldMenuModalWrapper, which this PR's callers already use.

This PR's getHoldMenuAmounts already returns nonHeldAmount: undefined when the report has no non-held expenses or the amount isn't valid. Both callers, PayActionButton and useSelectionModeReportActions, already get their amounts from it. Nothing in src/ or tests/ still refers to the deleted files.

I couldn't run typecheck or Jest in this environment, so CI will be the first check on the merged code.

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@roryabraham
Let's merge!

@ZhenjaHorbach

Copy link
Copy Markdown
Contributor

@MelvinBot
Fix Eslint issues

…fault-export

Co-authored-by: Yauheni Horbach <ZhenjaHorbach@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

I fixed the ESLint failure and pushed the change in ab75b25.

The only error was import/prefer-default-export in src/libs/HoldMenuUtils.ts:33. The file had a single named export. getHoldMenuAmounts is now the default export, and I updated its four importers:

  • MoneyReportHeaderModals.tsx
  • PayActionButton.tsx
  • useSelectionModeReportActions.ts
  • tests/unit/HoldMenuUtilsTest.ts

I couldn't run ESLint here, so the new CI run will confirm the fix. The other failing check, Check independent approval, needs a reviewer's approval and isn't a code issue.

@roryabraham

Copy link
Copy Markdown
Contributor

@MelvinBot are the failing reassure tests related?

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No, the failing Reassure check looks unrelated to this PR. It's a flaky render-count measurement that is failing the same way on unrelated branches today.

Evidence

What failed: validate-perf-tests flagged one measurement, [ReportActionsList] should re-render when the report name changes. Its average render count went from 27.10 to 27.80, and the check allows a difference of 0.

Why it looks like noise:

  • The render counts are fractional on both sides (27.10 → 27.80). That means the count already varies from one run to the next, even on main.
  • The test renders 500 plain chat actions (CREATED and ADDCOMMENT) and renames the report. It doesn't render report previews, the selection toolbar, or the money report header, which are the areas this PR changes. See tests/perf-test/ReportActionsListRowWrites.perf-test.tsx:185.
  • Other PR branches failed today on the same ReportActionsList measurements, with differences of about 0.6:
    • rodrigo-image-auth-recovery: same "report name changes" test, +0.6 (run)
    • fix/96225-account-switcher-keyboard-navigation: "unrelated transaction is written", +0.6 (run)
    • war-in/fix-tooltip-stale-position-rhp-resize: "unrelated transaction is written", +0.6 (run)
    • fix/99931: "unrelated transaction is written", +0.6 (run)

Re-running the job should likely clear it.

@roryabraham
roryabraham merged commit 6ffe4a3 into main Oct 30, 2026
44 of 46 checks passed
@roryabraham
roryabraham deleted the claude-replaceProcessMoneyReportHoldMenu branch October 30, 2026 18:58
@github-actions

Copy link
Copy Markdown
Contributor

🚧 roryabraham has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@github-actions

Copy link
Copy Markdown
Contributor

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/roryabraham in version: 9.5.27-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor Author

No help site update needed: this PR swaps the old hold menu component for the shared hold menu modal. The prompts, the options, and the payment flow users see stay the same.

@OSBotify

OSBotify commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/blimpich in version: 9.5.27-2 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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

Labels

Melvin-Test-Android Melvin-Test-Web Triggers Melvin to run the testing steps of the PR on web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants