Skip to content

Commit 602db0e

Browse files
committed
fix: User is prompted for account validation to pay manually
1 parent 229b1c2 commit 602db0e

2 files changed

Lines changed: 92 additions & 85 deletions

File tree

src/components/MoneyReportHeader.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,21 +1577,25 @@ function MoneyReportHeader({reportID: reportIDProp, shouldDisplayBackButton = fa
15771577
const hasApproveAction = primaryAction === CONST.REPORT.PRIMARY_ACTIONS.APPROVE || secondaryActions.includes(CONST.REPORT.SECONDARY_ACTIONS.APPROVE);
15781578
const hasPayAction = primaryAction === CONST.REPORT.PRIMARY_ACTIONS.PAY || secondaryActions.includes(CONST.REPORT.SECONDARY_ACTIONS.PAY);
15791579

1580-
const checkForNecessaryAction = useCallback(() => {
1581-
if (isDelegateAccessRestricted) {
1582-
showDelegateNoAccessModal();
1583-
return true;
1584-
}
1585-
if (isAccountLocked) {
1586-
showLockedAccountModal();
1587-
return true;
1588-
}
1589-
if (!isUserValidated) {
1590-
handleUnvalidatedAccount(moneyRequestReport);
1591-
return true;
1592-
}
1593-
return false;
1594-
}, [isDelegateAccessRestricted, showDelegateNoAccessModal, isAccountLocked, showLockedAccountModal, isUserValidated, moneyRequestReport]);
1580+
const checkForNecessaryAction = useCallback(
1581+
(paymentMethodType?: PaymentMethodType) => {
1582+
if (isDelegateAccessRestricted) {
1583+
showDelegateNoAccessModal();
1584+
return true;
1585+
}
1586+
if (isAccountLocked) {
1587+
showLockedAccountModal();
1588+
return true;
1589+
}
1590+
if (!isUserValidated && paymentMethodType !== CONST.IOU.PAYMENT_TYPE.ELSEWHERE) {
1591+
handleUnvalidatedAccount(moneyRequestReport);
1592+
return true;
1593+
}
1594+
1595+
return false;
1596+
},
1597+
[isDelegateAccessRestricted, showDelegateNoAccessModal, isAccountLocked, showLockedAccountModal, isUserValidated, moneyRequestReport],
1598+
);
15951599

15961600
const selectionModeReportLevelActions = useMemo(() => {
15971601
if (isProduction) {
@@ -2333,7 +2337,7 @@ function MoneyReportHeader({reportID: reportIDProp, shouldDisplayBackButton = fa
23332337
(fromSelectionMode: boolean) => (event: KYCFlowEvent, iouPaymentType: PaymentMethodType, triggerKYCFlow: TriggerKYCFlow) => {
23342338
if (fromSelectionMode) {
23352339
isSelectionModePaymentRef.current = true;
2336-
if (checkForNecessaryAction()) {
2340+
if (checkForNecessaryAction(iouPaymentType)) {
23372341
return;
23382342
}
23392343
}

src/components/SettlementButton/index.tsx

Lines changed: 72 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -183,73 +183,76 @@ function SettlementButton({
183183
return formattedPaymentMethods.filter((ba) => (ba.accountData as AccountData)?.type === CONST.BANK_ACCOUNT.TYPE.PERSONAL);
184184
}
185185

186-
const checkForNecessaryAction = useCallback(() => {
187-
if (isDelegateAccessRestricted) {
188-
showDelegateNoAccessModal();
189-
return true;
190-
}
186+
const checkForNecessaryAction = useCallback(
187+
(paymentMethodType?: PaymentMethodType) => {
188+
if (isDelegateAccessRestricted) {
189+
showDelegateNoAccessModal();
190+
return true;
191+
}
191192

192-
if (isAccountLocked) {
193-
showLockedAccountModal();
194-
return true;
195-
}
193+
if (isAccountLocked) {
194+
showLockedAccountModal();
195+
return true;
196+
}
196197

197-
if (!isUserValidated) {
198-
handleUnvalidatedUserNavigation(chatReportID, reportID);
199-
return true;
200-
}
198+
if (!isUserValidated && paymentMethodType !== CONST.IOU.PAYMENT_TYPE.ELSEWHERE) {
199+
handleUnvalidatedUserNavigation(chatReportID, reportID);
200+
return true;
201+
}
201202

202-
if (isBankAccountLocked) {
203-
showConfirmModal({
204-
title: translate('bankAccount.lockedBankAccount'),
205-
prompt: (
206-
<View style={[styles.renderHTML, styles.flexRow]}>
207-
<RenderHTML html={translate('bankAccount.youCantPayThis')} />
208-
</View>
209-
),
210-
confirmText: translate('bankAccount.unlockBankAccount'),
211-
cancelText: translate('common.cancel'),
212-
}).then(({action}) => {
213-
if (action !== ModalActions.CONFIRM) {
214-
return;
215-
}
216-
if (policy?.achAccount?.bankAccountID === undefined) {
217-
return;
218-
}
219-
pressLockedBankAccount(policy?.achAccount?.bankAccountID, translate, conciergeReportID);
220-
navigateToConciergeChat(conciergeReportID, introSelected, currentUserAccountID, isSelfTourViewed, betas);
221-
});
222-
return true;
223-
}
203+
if (isBankAccountLocked) {
204+
showConfirmModal({
205+
title: translate('bankAccount.lockedBankAccount'),
206+
prompt: (
207+
<View style={[styles.renderHTML, styles.flexRow]}>
208+
<RenderHTML html={translate('bankAccount.youCantPayThis')} />
209+
</View>
210+
),
211+
confirmText: translate('bankAccount.unlockBankAccount'),
212+
cancelText: translate('common.cancel'),
213+
}).then(({action}) => {
214+
if (action !== ModalActions.CONFIRM) {
215+
return;
216+
}
217+
if (policy?.achAccount?.bankAccountID === undefined) {
218+
return;
219+
}
220+
pressLockedBankAccount(policy?.achAccount?.bankAccountID, translate, conciergeReportID);
221+
navigateToConciergeChat(conciergeReportID, introSelected, currentUserAccountID, isSelfTourViewed, betas);
222+
});
223+
return true;
224+
}
224225

225-
if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGraceEndPeriod, userBillingGraceEndPeriods)) {
226-
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
227-
return true;
228-
}
226+
if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGraceEndPeriod, userBillingGraceEndPeriods)) {
227+
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
228+
return true;
229+
}
229230

230-
return false;
231-
}, [
232-
isDelegateAccessRestricted,
233-
isAccountLocked,
234-
isUserValidated,
235-
isBankAccountLocked,
236-
policy,
237-
userBillingGraceEndPeriods,
238-
ownerBillingGraceEndPeriod,
239-
showDelegateNoAccessModal,
240-
showLockedAccountModal,
241-
chatReportID,
242-
reportID,
243-
showConfirmModal,
244-
translate,
245-
styles.renderHTML,
246-
styles.flexRow,
247-
conciergeReportID,
248-
introSelected,
249-
currentUserAccountID,
250-
isSelfTourViewed,
251-
betas,
252-
]);
231+
return false;
232+
},
233+
[
234+
isDelegateAccessRestricted,
235+
isAccountLocked,
236+
isUserValidated,
237+
isBankAccountLocked,
238+
policy,
239+
userBillingGraceEndPeriods,
240+
ownerBillingGraceEndPeriod,
241+
showDelegateNoAccessModal,
242+
showLockedAccountModal,
243+
chatReportID,
244+
reportID,
245+
showConfirmModal,
246+
translate,
247+
styles.renderHTML,
248+
styles.flexRow,
249+
conciergeReportID,
250+
introSelected,
251+
currentUserAccountID,
252+
isSelfTourViewed,
253+
betas,
254+
],
255+
);
253256

254257
const shortFormPayElsewhereButton = {
255258
text: translate('iou.pay'),
@@ -320,7 +323,7 @@ function SettlementButton({
320323
value: CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT,
321324
description: account.description,
322325
onSelected: () => {
323-
if (checkForNecessaryAction()) {
326+
if (checkForNecessaryAction(CONST.IOU.PAYMENT_TYPE.VBBA)) {
324327
return;
325328
}
326329
onPress({
@@ -383,7 +386,7 @@ function SettlementButton({
383386
icon: formattedPaymentMethod?.icon,
384387
shouldUpdateSelectedIndex: true,
385388
onSelected: () => {
386-
if (checkForNecessaryAction()) {
389+
if (checkForNecessaryAction(CONST.IOU.PAYMENT_TYPE.EXPENSIFY)) {
387390
return;
388391
}
389392
onPress({
@@ -442,7 +445,7 @@ function SettlementButton({
442445
value: CONST.IOU.PAYMENT_TYPE.ELSEWHERE,
443446
shouldUpdateSelectedIndex: true,
444447
onSelected: () => {
445-
if (checkForNecessaryAction()) {
448+
if (checkForNecessaryAction(CONST.IOU.PAYMENT_TYPE.ELSEWHERE)) {
446449
return;
447450
}
448451
onPress({paymentType: CONST.IOU.PAYMENT_TYPE.ELSEWHERE, payAsBusiness});
@@ -551,16 +554,16 @@ function SettlementButton({
551554
};
552555

553556
const handlePaymentSelection = (event: GestureResponderEvent | KeyboardEvent | undefined, selectedOption: string, triggerKYCFlow: (params: ContinueActionParams) => void) => {
554-
if (checkForNecessaryAction()) {
555-
return;
556-
}
557-
558557
const {paymentType, policyFromPaymentMethod, policyFromContext, shouldSelectPaymentMethod} = getActivePaymentType(
559558
selectedOption,
560559
activeAdminPolicies,
561560
businessBankAccountOptions,
562561
policyIDKey,
563562
);
563+
564+
if (checkForNecessaryAction(paymentType)) {
565+
return;
566+
}
564567
const isPayingWithMethod = paymentType !== CONST.IOU.PAYMENT_TYPE.ELSEWHERE;
565568

566569
if ((!!policyFromPaymentMethod || shouldSelectPaymentMethod) && (isPayingWithMethod || !!policyFromPaymentMethod)) {

0 commit comments

Comments
 (0)