Skip to content

Commit 15e4323

Browse files
authored
Merge pull request Expensify#63818 from allgandalf/patch-17
Add Ability: Prompting to enable the wallet if you have a non-US deposit account setup
2 parents 59e18d3 + 29e28aa commit 15e4323

7 files changed

Lines changed: 39 additions & 13 deletions

File tree

src/components/KYCWall/BaseKYCWall.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function KYCWall({
109109
}
110110

111111
if (paymentMethod === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT) {
112-
openPersonalBankAccountSetupView();
112+
openPersonalBankAccountSetupView({shouldSetUpUSBankAccount: isIOUReport(iouReport)});
113113
} else if (paymentMethod === CONST.PAYMENT_METHODS.DEBIT_CARD) {
114114
Navigation.navigate(addDebitCardRoute ?? ROUTES.HOME);
115115
} else if (paymentMethod === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT || policy) {

src/libs/PaymentUtils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,18 @@ type TriggerKYCFlow = (event: KYCFlowEvent, iouPaymentType: PaymentMethodType) =
2626
type AccountType = ValueOf<typeof CONST.PAYMENT_METHODS> | undefined;
2727

2828
/**
29-
* Check to see if user has either a debit card or personal bank account added that can be used with a wallet.
29+
* Check to see if user has either a debit card or personal US bank account added that can be used with a wallet.
3030
*/
3131
function hasExpensifyPaymentMethod(fundList: Record<string, Fund>, bankAccountList: Record<string, BankAccount>, shouldIncludeDebitCard = true): boolean {
3232
const validBankAccount = Object.values(bankAccountList).some((bankAccountJSON) => {
3333
const bankAccount = new BankAccountModel(bankAccountJSON);
3434

35-
return bankAccount.getPendingAction() !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && bankAccount.isOpen() && bankAccount.getType() === CONST.BANK_ACCOUNT.TYPE.PERSONAL;
35+
return (
36+
bankAccount.getPendingAction() !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE &&
37+
bankAccount.isOpen() &&
38+
bankAccount.getType() === CONST.BANK_ACCOUNT.TYPE.PERSONAL &&
39+
bankAccount?.getCountry() === CONST.COUNTRY.US
40+
);
3641
});
3742

3843
// Hide any billing cards that are not P2P debit cards for now because you cannot make them your default method, or delete them

src/libs/actions/BankAccounts.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ export {openOnfidoFlow, answerQuestionsForWallet, verifyIdentity, acceptWalletTe
5151

5252
type AccountFormValues = typeof ONYXKEYS.FORMS.PERSONAL_BANK_ACCOUNT_FORM | typeof ONYXKEYS.FORMS.REIMBURSEMENT_ACCOUNT_FORM;
5353

54+
type OpenPersonalBankAccountSetupViewProps = {
55+
/** The reportID of the report to redirect to once the flow is finished */
56+
exitReportID?: string;
57+
58+
/** The policyID of the policy to set the bank account on */
59+
policyID?: string;
60+
61+
/** The source of the bank account */
62+
source?: string;
63+
64+
/** Whether to set up a US bank account */
65+
shouldSetUpUSBankAccount?: boolean;
66+
67+
/** Whether the user is validated */
68+
isUserValidated?: boolean;
69+
};
70+
5471
function clearPlaid(): Promise<void | void[]> {
5572
Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, '');
5673
Onyx.set(ONYXKEYS.PLAID_CURRENT_EVENT, null);
@@ -74,7 +91,7 @@ function setPlaidEvent(eventName: string | null) {
7491
/**
7592
* Open the personal bank account setup flow, with an optional exitReportID to redirect to once the flow is finished.
7693
*/
77-
function openPersonalBankAccountSetupView(exitReportID?: string, policyID?: string, source?: string, isUserValidated = true) {
94+
function openPersonalBankAccountSetupView({exitReportID, policyID, source, shouldSetUpUSBankAccount = false, isUserValidated = true}: OpenPersonalBankAccountSetupViewProps) {
7895
clearInternationalBankAccount().then(() => {
7996
if (exitReportID) {
8097
Onyx.merge(ONYXKEYS.PERSONAL_BANK_ACCOUNT, {exitReportID});
@@ -89,6 +106,10 @@ function openPersonalBankAccountSetupView(exitReportID?: string, policyID?: stri
89106
Navigation.navigate(ROUTES.SETTINGS_CONTACT_METHOD_VERIFY_ACCOUNT.getRoute(Navigation.getActiveRoute(), ROUTES.SETTINGS_ADD_BANK_ACCOUNT.route));
90107
return;
91108
}
109+
if (shouldSetUpUSBankAccount) {
110+
Navigation.navigate(ROUTES.SETTINGS_ADD_US_BANK_ACCOUNT);
111+
return;
112+
}
92113
Navigation.navigate(ROUTES.SETTINGS_ADD_BANK_ACCOUNT.getRoute(Navigation.getActiveRoute()));
93114
});
94115
}

src/pages/home/report/PureReportActionItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ function PureReportActionItem({
969969
success
970970
style={[styles.w100, styles.requestPreviewBox]}
971971
text={translate('bankAccount.addBankAccount')}
972-
onPress={() => openPersonalBankAccountSetupView(Navigation.getTopmostReportId() ?? targetReport?.reportID, undefined, undefined, isUserValidated)}
972+
onPress={() => openPersonalBankAccountSetupView({exitReportID: Navigation.getTopmostReportId() ?? targetReport?.reportID, isUserValidated})}
973973
pressOnEnter
974974
large
975975
/>

src/pages/settings/Wallet/ChooseTransferAccountPage.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import useOnyx from '@hooks/useOnyx';
1515
import useThemeStyles from '@hooks/useThemeStyles';
1616
import {getLastFourDigits} from '@libs/BankAccountUtils';
1717
import Navigation from '@libs/Navigation/Navigation';
18-
import * as BankAccounts from '@userActions/BankAccounts';
19-
import * as PaymentMethods from '@userActions/PaymentMethods';
18+
import {openPersonalBankAccountSetupView} from '@userActions/BankAccounts';
19+
import {saveWalletTransferAccountTypeAndID} from '@userActions/PaymentMethods';
2020
import CONST from '@src/CONST';
2121
import ONYXKEYS from '@src/ONYXKEYS';
2222
import ROUTES from '@src/ROUTES';
@@ -30,7 +30,7 @@ type BankAccountListItem = ListItem & {
3030
};
3131

3232
function ChooseTransferAccountPage() {
33-
const [walletTransfer, walletTransferResult] = useOnyx(ONYXKEYS.WALLET_TRANSFER);
33+
const [walletTransfer, walletTransferResult] = useOnyx(ONYXKEYS.WALLET_TRANSFER, {canBeMissing: true});
3434

3535
const styles = useThemeStyles();
3636
const {translate} = useLocalize();
@@ -41,7 +41,7 @@ function ChooseTransferAccountPage() {
4141
* @param account of the selected account data
4242
*/
4343
const selectAccountAndNavigateBack = (accountType?: string, account?: AccountData) => {
44-
PaymentMethods.saveWalletTransferAccountTypeAndID(
44+
saveWalletTransferAccountTypeAndID(
4545
accountType ?? '',
4646
(accountType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT ? account?.bankAccountID?.toString() : account?.fundID?.toString()) ?? '',
4747
);
@@ -53,10 +53,10 @@ function ChooseTransferAccountPage() {
5353
Navigation.navigate(ROUTES.SETTINGS_ADD_DEBIT_CARD);
5454
return;
5555
}
56-
BankAccounts.openPersonalBankAccountSetupView();
56+
openPersonalBankAccountSetupView({});
5757
};
5858

59-
const [bankAccountsList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
59+
const [bankAccountsList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST, {canBeMissing: true});
6060
const selectedAccountID = walletTransfer?.selectedAccountID;
6161
const data = useMemo(() => {
6262
const options = Object.values(bankAccountsList ?? {}).map((bankAccount): BankAccountListItem => {

src/pages/settings/Wallet/WalletPage/WalletPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ function WalletPage({shouldListenForResize = false}: WalletPageProps) {
250250
return;
251251
}
252252
if (paymentType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT || paymentType === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT) {
253-
openPersonalBankAccountSetupView();
253+
openPersonalBankAccountSetupView({});
254254
return;
255255
}
256256

src/pages/workspace/invoices/WorkspaceInvoiceVBASection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function WorkspaceInvoiceVBASection({policyID}: WorkspaceInvoiceVBASectionProps)
167167
const addPaymentMethodTypePressed = (paymentType: string) => {
168168
hideAddPaymentMenu();
169169
if (paymentType === CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT || paymentType === CONST.PAYMENT_METHODS.BUSINESS_BANK_ACCOUNT) {
170-
openPersonalBankAccountSetupView(undefined, policyID, 'invoice', isUserValidated);
170+
openPersonalBankAccountSetupView({policyID, source: 'invoice', isUserValidated});
171171
return;
172172
}
173173

0 commit comments

Comments
 (0)