Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/hooks/useSelectionModeReportActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function useSelectionModeReportActions({
const [requestType, setRequestType] = useState<ActionHandledType>();
const [selectedVBBAToPayFromHoldMenu, setSelectedVBBAToPayFromHoldMenu] = useState<number | undefined>(undefined);

const shouldBlockAction = () => {
const shouldBlockAction = (paymentMethodType?: PaymentMethodType) => {
if (isDelegateAccessRestricted) {
showDelegateNoAccessModal();
return true;
Expand All @@ -266,7 +266,7 @@ function useSelectionModeReportActions({
showLockedAccountModal();
return true;
}
if (!isUserValidated) {
if (!isUserValidated && paymentMethodType !== CONST.IOU.PAYMENT_TYPE.ELSEWHERE) {
handleUnvalidatedAccount(report);
return true;
}
Expand Down Expand Up @@ -420,7 +420,7 @@ function useSelectionModeReportActions({
const handlePaySelected = () => {};

const onSelectionModePaymentSelect = (event: KYCFlowEvent, iouPaymentType: PaymentMethodType, triggerKYCFlow: TriggerKYCFlow) => {
if (shouldBlockAction()) {
if (shouldBlockAction(iouPaymentType)) {
return;
}
// This callback fires via onSubItemSelected before the popover closes. Defer heavy payment
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/hooks/useSelectionModeReportActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,26 @@ describe('useSelectionModeReportActions', () => {

expect(blocked).toBe(false);
});

it('returns true for unvalidated user when payment type is not Elsewhere', async () => {
await Onyx.merge(ONYXKEYS.ACCOUNT, {validated: false});
await waitForBatchedUpdates();

const {result} = renderSelectionModeHook();
const blocked = result.current.shouldBlockAction(CONST.IOU.PAYMENT_TYPE.EXPENSIFY);

expect(blocked).toBe(true);
});

it('returns false for unvalidated user when payment type is Elsewhere', async () => {
await Onyx.merge(ONYXKEYS.ACCOUNT, {validated: false});
await waitForBatchedUpdates();

const {result} = renderSelectionModeHook();
const blocked = result.current.shouldBlockAction(CONST.IOU.PAYMENT_TYPE.ELSEWHERE);

expect(blocked).toBe(false);
});
});

describe('handleSubmitReport guards', () => {
Expand Down
Loading