From 0daeceafc83bda21c85ef56e29129f417ed1a70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez=20=28via=20MelvinBot=29?= Date: Tue, 8 Sep 2026 20:23:39 +0000 Subject: [PATCH 1/2] Gate the partial pay/approve option on the non-held amount instead of hasNonHeldExpenses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marco Chávez --- src/components/Modal/Global/HoldMenuModalWrapper.tsx | 7 +++++-- src/components/ProcessMoneyReportHoldMenu.tsx | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/Modal/Global/HoldMenuModalWrapper.tsx b/src/components/Modal/Global/HoldMenuModalWrapper.tsx index 1bea9e5d2b72..ce22ebc8a7f2 100644 --- a/src/components/Modal/Global/HoldMenuModalWrapper.tsx +++ b/src/components/Modal/Global/HoldMenuModalWrapper.tsx @@ -45,7 +45,7 @@ function HoldMenuModalWrapper({ requestType, paymentType, methodID, - nonHeldAmount = '0', + nonHeldAmount, fullAmount, hasNonHeldExpenses, transactionCount, @@ -88,7 +88,10 @@ function HoldMenuModalWrapper({ onClose={() => setIsVisible(false)} isVisible={isVisible} prompt={approvalPrompt} - firstOptionText={hasNonHeldExpenses ? `${translate(isApprove ? 'iou.approveOnly' : 'iou.payOnly')} ${nonHeldAmount}` : undefined} + // Callers pass `undefined` when the non-held amount isn't meaningfully different from the full amount, + // so gate on the amount itself rather than on `hasNonHeldExpenses` — otherwise a report whose unheld + // expenses net out to nothing offers a partial option for a zero amount. + firstOptionText={nonHeldAmount !== undefined ? `${translate(isApprove ? 'iou.approveOnly' : 'iou.payOnly')} ${nonHeldAmount}` : undefined} secondOptionText={`${translate(isApprove ? 'iou.approve' : 'iou.pay')} ${fullAmount}`} onFirstOptionSubmit={() => onSubmit(false)} onSecondOptionSubmit={() => onSubmit(true)} diff --git a/src/components/ProcessMoneyReportHoldMenu.tsx b/src/components/ProcessMoneyReportHoldMenu.tsx index 7ecb6b1d6a01..14750d5f81b4 100644 --- a/src/components/ProcessMoneyReportHoldMenu.tsx +++ b/src/components/ProcessMoneyReportHoldMenu.tsx @@ -48,7 +48,7 @@ type ProcessMoneyReportHoldMenuProps = { }; function ProcessMoneyReportHoldMenu({ - nonHeldAmount = '0', + nonHeldAmount, fullAmount, onClose, isVisible, @@ -81,7 +81,10 @@ function ProcessMoneyReportHoldMenu({ onClose={onClose} isVisible={isVisible} prompt={promptText} - firstOptionText={hasNonHeldExpenses ? `${translate('iou.payOnly')} ${nonHeldAmount}` : undefined} + // Callers pass `undefined` when the non-held amount isn't meaningfully different from the full amount, + // so gate on the amount itself rather than on `hasNonHeldExpenses` — otherwise a report whose unheld + // expenses net out to nothing offers a partial option for a zero amount. + firstOptionText={nonHeldAmount !== undefined ? `${translate('iou.payOnly')} ${nonHeldAmount}` : undefined} secondOptionText={`${translate('iou.pay')} ${fullAmount}`} onFirstOptionSubmit={() => onSubmit(false)} onSecondOptionSubmit={() => onSubmit(true)} From 71aa77a653f738f2eeda80fe627ee04100b8ec67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Ch=C3=A1vez=20=28via=20MelvinBot=29?= Date: Tue, 8 Sep 2026 20:30:32 +0000 Subject: [PATCH 2/2] Add regression test for the partial approve option gating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marco Chávez --- tests/unit/HoldMenuModalWrapperTest.tsx | 66 +++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 tests/unit/HoldMenuModalWrapperTest.tsx diff --git a/tests/unit/HoldMenuModalWrapperTest.tsx b/tests/unit/HoldMenuModalWrapperTest.tsx new file mode 100644 index 000000000000..61c0d4624fdc --- /dev/null +++ b/tests/unit/HoldMenuModalWrapperTest.tsx @@ -0,0 +1,66 @@ +import {render} from '@testing-library/react-native'; + +import type {DecisionModalProps} from '@components/DecisionModal'; +import HoldMenuModalWrapper from '@components/Modal/Global/HoldMenuModalWrapper'; + +import CONST from '@src/CONST'; + +let mockDecisionModalProps: DecisionModalProps | undefined; + +jest.mock('@components/DecisionModal', () => { + return (props: DecisionModalProps) => { + mockDecisionModalProps = props; + return null; + }; +}); + +jest.mock('@hooks/useHoldMenuSubmit', () => ({ + __esModule: true, + default: () => ({onSubmit: jest.fn(), isApprove: true}), +})); + +jest.mock('@hooks/useOnyx', () => ({ + __esModule: true, + default: () => [undefined], +})); + +function renderWrapper(overrides: {nonHeldAmount?: string; hasNonHeldExpenses?: boolean}) { + return render( + , + ); +} + +describe('HoldMenuModalWrapper', () => { + beforeEach(() => { + mockDecisionModalProps = undefined; + }); + + it('offers the partial approve option when a valid non-held amount is supplied', () => { + renderWrapper({nonHeldAmount: '$40.00', hasNonHeldExpenses: true}); + + expect(mockDecisionModalProps?.firstOptionText).toContain('$40.00'); + }); + + it('omits the partial approve option when the non-held amount is not meaningful, even though non-held expenses exist', () => { + // The report still has an unheld expense, but its amount nets out against the held one, so the caller + // sends `undefined` rather than an amount. The modal must not fall back to rendering a zero amount. + renderWrapper({nonHeldAmount: undefined, hasNonHeldExpenses: true}); + + expect(mockDecisionModalProps?.firstOptionText).toBeUndefined(); + }); + + it('omits the partial approve option when every expense is on hold', () => { + renderWrapper({nonHeldAmount: undefined, hasNonHeldExpenses: false}); + + expect(mockDecisionModalProps?.firstOptionText).toBeUndefined(); + }); +});