Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store account validated state and display error early on VBA flow #5524

Merged
merged 6 commits into from
Sep 27, 2021
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
1 change: 1 addition & 0 deletions src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const MenuItem = ({
getButtonBackgroundColorStyle(getButtonState(focused || hovered, pressed, success, disabled)),
wrapperStyle,
])}
disabled={disabled}
>
{({hovered, pressed}) => (
<>
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ export default {
toGetStarted: 'To get started with the Expensify Card, you first need to add a bank account.',
plaidBodyCopy: 'Give your employees an easier way to pay - and get paid back - for company expenses.',
checkHelpLine: 'Your routing number and account number can be found on a check for the account.',
validateAccountError: 'In order to finish setting up your bank account, you must validate your account. Please check your email to validate your account, and return here to finish up!',
hasPhoneLoginError: 'To add a verified bank account please ensure your primary login is a valid email and try again. You can add your phone number as a secondary login.',
hasBeenThrottledError: ({fromNow}) => `For security reasons, we're taking a break from bank account setup so you can double-check your company information. Please try again ${fromNow}. Sorry!`,
buttonConfirm: 'Got it',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ export default {
toGetStarted: 'Para comenzar con la tarjeta Expensify, primero debe agregar una cuenta bancaria.',
plaidBodyCopy: 'Ofrezca a sus empleados una forma más sencilla de pagar - y recuperar - los gastos de la empresa.',
checkHelpLine: 'Su número de ruta y número de cuenta se pueden encontrar en un cheque de la cuenta bancaria.',
validateAccountError: 'Para terminar de configurar tu cuenta bancaria, debes validar tu cuenta de Expensify. Por favor revisa tu correo electrónico para validar tu cuenta y regresa aquí para continuar.',
hasPhoneLoginError: 'Para agregar una cuenta bancaria verificada, asegúrate de que tu nombre de usuario principal sea un correo electrónico válido y vuelve a intentarlo. Puedes agregar tu número de teléfono como nombre de usuario secundario.',
hasBeenThrottledError: ({fromNow}) => `Por razones de seguridad, nos tomamos un descanso en la configuración de la cuenta bancaria para que pueda verificar la información de su empresa. Inténtalo de nuevo ${fromNow}. ¡Lo siento!`,
buttonConfirm: 'OK',
Expand Down
3 changes: 2 additions & 1 deletion src/libs/actions/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ function getUserDetails() {
// Update the User onyx key
const loginList = _.where(response.loginList, {partnerName: 'expensify.com'});
const expensifyNewsStatus = lodashGet(response, 'account.subscribed', true);
Onyx.merge(ONYXKEYS.USER, {loginList, expensifyNewsStatus: !!expensifyNewsStatus});
const validatedStatus = lodashGet(response, 'account.validated', false);
Onyx.merge(ONYXKEYS.USER, {loginList, expensifyNewsStatus: !!expensifyNewsStatus, validated: !!validatedStatus});

// Update the nvp_payPalMeAddress NVP
const payPalMeAddress = lodashGet(response, `nameValuePairs.${CONST.NVP.PAYPAL_ME_ADDRESS}`, '');
Expand Down
18 changes: 16 additions & 2 deletions src/pages/ReimbursementAccount/BankAccountStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {withOnyx} from 'react-native-onyx';
import HeaderWithCloseButton from '../../components/HeaderWithCloseButton';
import MenuItem from '../../components/MenuItem';
import {
Paycheck, Bank, Lock,
Paycheck, Bank, Lock, Exclamation,
} from '../../components/Icon/Expensicons';
import styles from '../../styles/styles';
import TextLink from '../../components/TextLink';
Expand Down Expand Up @@ -182,7 +182,7 @@ class BankAccountStep extends React.Component {
icon={Bank}
title={this.props.translate('bankAccount.logIntoYourBank')}
onPress={() => setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID)}
disabled={this.props.isPlaidDisabled}
disabled={this.props.isPlaidDisabled || !this.props.user.validated}
shouldShowRightIcon
/>
{this.props.isPlaidDisabled && (
Expand All @@ -193,9 +193,20 @@ class BankAccountStep extends React.Component {
<MenuItem
icon={Paycheck}
title={this.props.translate('bankAccount.connectManually')}
disabled={!this.props.user.validated}
onPress={() => setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL)}
shouldShowRightIcon
/>
{!this.props.user.validated && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 I'm not sure if this was true at the time of creation of this PR, but this might have caused an issue in #18156
This is an edge case, which can be reproduced only if you clear cookies and site data and then sign in again

Before the API call to get user info is completed,this.props.user.validated is undefined, which causes validateAccountError to display for a split second while API call is in progress
We resolved this by displaying a loading indicator while the API call is in progress, but that didn't exist when this PR was created, so {this.props.user.validated === false && ( would have avoided this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, great catch and that makes sense 🤯

<View style={[styles.flexRow, styles.alignItemsCenter, styles.m4]}>
<Text style={[styles.mutedTextLabel, styles.mr4]}>
<Icon src={Exclamation} fill={colors.red} />
</Text>
<Text style={styles.mutedTextLabel}>
{this.props.translate('bankAccount.validateAccountError')}
</Text>
</View>
)}
<View style={[styles.m5, styles.flexRow, styles.justifyContentBetween]}>
<TextLink href="https://use.expensify.com/privacy">
{this.props.translate('common.privacy')}
Expand Down Expand Up @@ -285,5 +296,8 @@ export default compose(
reimbursementAccountDraft: {
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT_DRAFT,
},
user: {
key: ONYXKEYS.USER,
},
}),
)(BankAccountStep);