Skip to content

Commit

Permalink
Merge pull request Expensify#30114 from Expensify/marcaaron-preventAc…
Browse files Browse the repository at this point in the history
…tivateWalletOnOnfidoFailure

[CP staging] Prevent second attempts to activate wallet when Onfido checks fail
  • Loading branch information
MariaHCD authored Oct 24, 2023
2 parents d282473 + c0f2e74 commit 4430ae2
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,7 @@ export default {
assignedCardsDescription: 'These are cards assigned by a Workspace admin to manage company spend.',
expensifyCard: 'Expensify Card',
walletActivationPending: "We're reviewing your information, please check back in a few minutes!",
walletActivationFailed: 'Unfortunately your wallet cannot be enabled at this time. Please chat with Concierge for further assistance.',
},
cardPage: {
expensifyCard: 'Expensify Card',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ export default {
assignedCardsDescription: 'Son tarjetas asignadas por un administrador del Espacio de Trabajo para gestionar los gastos de la empresa.',
expensifyCard: 'Tarjeta Expensify',
walletActivationPending: 'Estamos revisando su información, por favor vuelve en unos minutos.',
walletActivationFailed: 'Lamentablemente, no podemos activar tu billetera en este momento. Chatea con Concierge para obtener más ayuda.',
},
cardPage: {
expensifyCard: 'Tarjeta Expensify',
Expand Down
11 changes: 6 additions & 5 deletions src/pages/EnablePayments/EnablePaymentsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@ function EnablePaymentsPage({userWallet}) {
const {translate} = useLocalize();
const {isOffline} = useNetwork();

const {isPendingOnfidoResult} = userWallet;
const {isPendingOnfidoResult, hasFailedOnfido} = userWallet;

useEffect(() => {
if (isOffline) {
return;
}

if (!isPendingOnfidoResult) {
Wallet.openEnablePaymentsPage();
} else {
if (isPendingOnfidoResult || hasFailedOnfido) {
Navigation.navigate(ROUTES.SETTINGS_WALLET, CONST.NAVIGATION.TYPE.UP);
return;
}
}, [isOffline, isPendingOnfidoResult]);

Wallet.openEnablePaymentsPage();
}, [isOffline, isPendingOnfidoResult, hasFailedOnfido]);

if (_.isEmpty(userWallet)) {
return <FullScreenLoadingIndicator />;
Expand Down
3 changes: 3 additions & 0 deletions src/pages/EnablePayments/userWalletPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ export default PropTypes.shape({

/** The wallet's programID, used to show the correct terms. */
walletProgramID: PropTypes.string,

/** Whether the user has failed Onfido completely */
hasFailedOnfido: PropTypes.bool,
});
19 changes: 17 additions & 2 deletions src/pages/settings/Wallet/WalletPage/WalletPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function WalletPage({bankAccountList, betas, cardList, fundList, isLoadingPaymen
const shouldShowEmptyState = !hasBankAccount && !hasWallet && !hasAssignedCard;

const isPendingOnfidoResult = lodashGet(userWallet, 'isPendingOnfidoResult', false);
const hasFailedOnfido = lodashGet(userWallet, 'hasFailedOnfido', false);

const updateShouldShowLoadingSpinner = useCallback(() => {
// In order to prevent a loop, only update state of the spinner if there is a change
Expand Down Expand Up @@ -311,6 +312,8 @@ function WalletPage({bankAccountList, betas, cardList, fundList, isLoadingPaymen

// Determines whether or not the modal popup is mounted from the bottom of the screen instead of the side mount on Web or Desktop screens
const isPopoverBottomMount = anchorPosition.anchorPositionTop === 0 || isSmallScreenWidth;
const alertTextStyle = [styles.inlineSystemMessage, styles.flexShrink1];
const alertViewStyle = [styles.flexRow, styles.alignItemsCenter, styles.w100, styles.ph5];

return (
<>
Expand Down Expand Up @@ -393,12 +396,24 @@ function WalletPage({bankAccountList, betas, cardList, fundList, isLoadingPaymen

if (isPendingOnfidoResult) {
return (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.w100, styles.ph5]}>
<View style={alertViewStyle}>
<Icon
src={Expensicons.Hourglass}
fill={themeColors.icon}
/>
<Text style={[styles.inlineSystemMessage, styles.flexShrink1]}>{translate('walletPage.walletActivationPending')}</Text>
<Text style={alertTextStyle}>{translate('walletPage.walletActivationPending')}</Text>
</View>
);
}

if (hasFailedOnfido) {
return (
<View style={alertViewStyle}>
<Icon
src={Expensicons.Exclamation}
fill={themeColors.icon}
/>
<Text style={alertTextStyle}>{translate('walletPage.walletActivationFailed')}</Text>
</View>
);
}
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/UserWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ type UserWallet = {
/** What step in the activation flow are we on? */
currentStep: ValueOf<typeof CONST.WALLET.STEP>;

/** If the user failed the Onfido verification check */
hasFailedOnfido?: boolean;

/** If we should show the FailedKYC view after the user submitted their info with a non fixable error */
shouldShowFailedKYC?: boolean;

Expand Down

0 comments on commit 4430ae2

Please sign in to comment.