Skip to content

Commit

Permalink
Merge pull request #10172 from Expensify/marcaaron-fixUserValidatedCrash
Browse files Browse the repository at this point in the history
Safer access of validated field to fix crash
  • Loading branch information
ctkochan22 authored Aug 2, 2022
2 parents 869db50 + 50e1715 commit 28778a0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/pages/ReimbursementAccount/BankAccountStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,19 @@ const propTypes = {
/** During the OAuth flow we need to use the plaidLink token that we initially connected with */
plaidLinkOAuthToken: PropTypes.string,

/** Object with various information about the user */
user: PropTypes.shape({
/** Is the user account validated? */
validated: PropTypes.bool,
}),

...withLocalizePropTypes,
};

const defaultProps = {
receivedRedirectURI: null,
plaidLinkOAuthToken: '',
user: {},
};

class BankAccountStep extends React.Component {
Expand Down Expand Up @@ -180,7 +187,7 @@ class BankAccountStep extends React.Component {
const bankAccountRoute = `${CONFIG.EXPENSIFY.NEW_EXPENSIFY_URL}${ROUTES.BANK_ACCOUNT}`;
const error = lodashGet(this.props, 'reimbursementAccount.error', '');
const loading = lodashGet(this.props, 'reimbursementAccount.loading', false);

const validated = lodashGet(this.props, 'user.validated', false);
return (
<View style={[styles.flex1, styles.justifyContentBetween]}>
<HeaderWithCloseButton
Expand Down Expand Up @@ -219,7 +226,7 @@ class BankAccountStep extends React.Component {
icon={Expensicons.Bank}
text={this.props.translate('bankAccount.connectOnlineWithPlaid')}
onPress={() => BankAccounts.setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID)}
disabled={this.props.isPlaidDisabled || !this.props.user.validated}
disabled={this.props.isPlaidDisabled || !validated}
style={[styles.mt5, styles.mh3]}
iconStyles={[styles.mr5]}
shouldShowRightIcon
Expand All @@ -234,11 +241,11 @@ class BankAccountStep extends React.Component {
<MenuItem
icon={Expensicons.Connect}
title={this.props.translate('bankAccount.connectManually')}
disabled={!this.props.user.validated}
disabled={!validated}
onPress={() => BankAccounts.setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL)}
shouldShowRightIcon
/>
{!this.props.user.validated && (
{!validated && (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.m4]}>
<Text style={[styles.mutedTextLabel, styles.mr4]}>
<Icon src={Expensicons.Exclamation} fill={colors.red} />
Expand Down

0 comments on commit 28778a0

Please sign in to comment.