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
2 changes: 1 addition & 1 deletion src/libs/actions/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ function handleBulkPayItemSelected(params: {
return;
}

if (!isUserValidated) {
if (!isUserValidated && item.key !== CONST.IOU.PAYMENT_TYPE.ELSEWHERE) {
Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.VERIFY_ACCOUNT.path));
return;
}
Expand Down
45 changes: 44 additions & 1 deletion tests/unit/Search/handleActionButtonPressTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import type {OnyxEntry} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {TransactionReportGroupListItemType} from '@components/Search/SearchList/ListItem/types';
import {handleActionButtonPress, handleBulkPayItemSelected} from '@libs/actions/Search';
import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES';
import type {LastPaymentMethod, Policy, Report, SearchResults} from '@src/types/onyx';
import createRandomPolicy from '../../utils/collections/policies';

Expand Down Expand Up @@ -498,4 +499,46 @@ describe('handleBulkPayItemSelected', () => {

expect(baseParams.confirmPayment).toHaveBeenCalled();
});

it('should not navigate to verify account and should call confirmPayment when user is unvalidated and item is Mark as paid (ELSEWHERE)', async () => {
const policy = {
...createRandomPolicy(Number(policyID)),
id: policyID,
ownerAccountID,
} as Policy;

await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, policy);

handleBulkPayItemSelected({
...baseParams,
policy,
amountOwed: 0,
isUserValidated: false,
item: {key: CONST.IOU.PAYMENT_TYPE.ELSEWHERE, text: 'Pay elsewhere', icon: () => null},
});

expect(Navigation.navigate).not.toHaveBeenCalledWith(createDynamicRoute(DYNAMIC_ROUTES.VERIFY_ACCOUNT.path));
expect(baseParams.confirmPayment).toHaveBeenCalled();
});

it('should navigate to verify account when user is unvalidated and item is a bank-funded payment type (VBBA)', async () => {
const policy = {
...createRandomPolicy(Number(policyID)),
id: policyID,
ownerAccountID,
} as Policy;

await Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, policy);

handleBulkPayItemSelected({
...baseParams,
policy,
amountOwed: 0,
isUserValidated: false,
item: {key: CONST.IOU.PAYMENT_TYPE.VBBA, text: 'Pay with bank account', icon: () => null},
});

expect(Navigation.navigate).toHaveBeenCalledWith(createDynamicRoute(DYNAMIC_ROUTES.VERIFY_ACCOUNT.path));
expect(baseParams.confirmPayment).not.toHaveBeenCalled();
});
});
Loading