Skip to content

Commit 69a3bdc

Browse files
authored
Merge pull request Expensify#86714 from paulnjs/paulnjs-fix/86383
fix: Don't require account validation to mark a report as paid manually
2 parents db29330 + 3bf4534 commit 69a3bdc

2 files changed

Lines changed: 93 additions & 86 deletions

File tree

src/components/MoneyReportHeader.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,21 +1174,25 @@ function MoneyReportHeaderContent({reportID: reportIDProp, shouldDisplayBackButt
11741174
const hasApproveAction = primaryAction === CONST.REPORT.PRIMARY_ACTIONS.APPROVE || secondaryActions.includes(CONST.REPORT.SECONDARY_ACTIONS.APPROVE);
11751175
const hasPayAction = primaryAction === CONST.REPORT.PRIMARY_ACTIONS.PAY || secondaryActions.includes(CONST.REPORT.SECONDARY_ACTIONS.PAY);
11761176

1177-
const checkForNecessaryAction = useCallback(() => {
1178-
if (isDelegateAccessRestricted) {
1179-
showDelegateNoAccessModal();
1180-
return true;
1181-
}
1182-
if (isAccountLocked) {
1183-
showLockedAccountModal();
1184-
return true;
1185-
}
1186-
if (!isUserValidated) {
1187-
handleUnvalidatedAccount(moneyRequestReport);
1188-
return true;
1189-
}
1190-
return false;
1191-
}, [isDelegateAccessRestricted, showDelegateNoAccessModal, isAccountLocked, showLockedAccountModal, isUserValidated, moneyRequestReport]);
1177+
const checkForNecessaryAction = useCallback(
1178+
(paymentMethodType?: PaymentMethodType) => {
1179+
if (isDelegateAccessRestricted) {
1180+
showDelegateNoAccessModal();
1181+
return true;
1182+
}
1183+
if (isAccountLocked) {
1184+
showLockedAccountModal();
1185+
return true;
1186+
}
1187+
if (!isUserValidated && paymentMethodType !== CONST.IOU.PAYMENT_TYPE.ELSEWHERE) {
1188+
handleUnvalidatedAccount(moneyRequestReport);
1189+
return true;
1190+
}
1191+
1192+
return false;
1193+
},
1194+
[isDelegateAccessRestricted, showDelegateNoAccessModal, isAccountLocked, showLockedAccountModal, isUserValidated, moneyRequestReport],
1195+
);
11921196

11931197
const selectionModeReportLevelActions = useMemo(() => {
11941198
if (isProduction) {
@@ -1909,7 +1913,7 @@ function MoneyReportHeaderContent({reportID: reportIDProp, shouldDisplayBackButt
19091913
(fromSelectionMode: boolean) => (event: KYCFlowEvent, iouPaymentType: PaymentMethodType, triggerKYCFlow: TriggerKYCFlow) => {
19101914
if (fromSelectionMode) {
19111915
isSelectionModePaymentRef.current = true;
1912-
if (checkForNecessaryAction()) {
1916+
if (checkForNecessaryAction(iouPaymentType)) {
19131917
return;
19141918
}
19151919
}

src/components/SettlementButton/index.tsx

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

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

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

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

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

226-
if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy)) {
227-
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
228-
return true;
229-
}
227+
if (policy && shouldRestrictUserBillableActions(policy.id, ownerBillingGracePeriodEnd, userBillingGracePeriodEnds, amountOwed, policy)) {
228+
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
229+
return true;
230+
}
230231

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

256259
const shortFormPayElsewhereButton = {
257260
text: translate('iou.pay'),
@@ -322,7 +325,7 @@ function SettlementButton({
322325
value: CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT,
323326
description: account.description,
324327
onSelected: () => {
325-
if (checkForNecessaryAction()) {
328+
if (checkForNecessaryAction(CONST.IOU.PAYMENT_TYPE.VBBA)) {
326329
return;
327330
}
328331
onPress({
@@ -385,7 +388,7 @@ function SettlementButton({
385388
icon: formattedPaymentMethod?.icon,
386389
shouldUpdateSelectedIndex: true,
387390
onSelected: () => {
388-
if (checkForNecessaryAction()) {
391+
if (checkForNecessaryAction(CONST.IOU.PAYMENT_TYPE.EXPENSIFY)) {
389392
return;
390393
}
391394
onPress({
@@ -444,7 +447,7 @@ function SettlementButton({
444447
value: CONST.IOU.PAYMENT_TYPE.ELSEWHERE,
445448
shouldUpdateSelectedIndex: true,
446449
onSelected: () => {
447-
if (checkForNecessaryAction()) {
450+
if (checkForNecessaryAction(CONST.IOU.PAYMENT_TYPE.ELSEWHERE)) {
448451
return;
449452
}
450453
onPress({paymentType: CONST.IOU.PAYMENT_TYPE.ELSEWHERE, payAsBusiness});
@@ -554,16 +557,16 @@ function SettlementButton({
554557
};
555558

556559
const handlePaymentSelection = (event: GestureResponderEvent | KeyboardEvent | undefined, selectedOption: string, triggerKYCFlow: (params: ContinueActionParams) => void) => {
557-
if (checkForNecessaryAction()) {
558-
return;
559-
}
560-
561560
const {paymentType, policyFromPaymentMethod, policyFromContext, shouldSelectPaymentMethod} = getActivePaymentType(
562561
selectedOption,
563562
activeAdminPolicies,
564563
businessBankAccountOptions,
565564
policyIDKey,
566565
);
566+
567+
if (checkForNecessaryAction(paymentType)) {
568+
return;
569+
}
567570
const isPayingWithMethod = paymentType !== CONST.IOU.PAYMENT_TYPE.ELSEWHERE;
568571

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

0 commit comments

Comments
 (0)