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

🍒 Cherry pick PR #11750 to staging 🍒 #11789

Merged
merged 2 commits into from
Oct 13, 2022
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
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001021304
versionName "1.2.13-4"
versionCode 1001021305
versionName "1.2.13-5"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

if (isNewArchitectureEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.2.13.4</string>
<string>1.2.13.5</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.2.13.4</string>
<string>1.2.13.5</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.2.13-4",
"version": "1.2.13-5",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
42 changes: 12 additions & 30 deletions src/components/AddPlaidBankAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const propTypes = {
/** Contains plaid data */
plaidData: plaidDataPropTypes,

/** Selected account ID from the Picker associated with the end of the Plaid flow */
selectedPlaidAccountID: PropTypes.string,

/** Plaid SDK token to use to initialize the widget */
plaidLinkToken: PropTypes.string,

Expand Down Expand Up @@ -61,6 +64,7 @@ const defaultProps = {
isLoading: false,
error: '',
},
selectedPlaidAccountID: '',
plaidLinkToken: '',
onExitPlaid: () => {},
onSelect: () => {},
Expand All @@ -75,7 +79,6 @@ class AddPlaidBankAccount extends React.Component {
constructor(props) {
super(props);

this.selectAccount = this.selectAccount.bind(this);
this.getPlaidLinkToken = this.getPlaidLinkToken.bind(this);
}

Expand All @@ -88,15 +91,6 @@ class AddPlaidBankAccount extends React.Component {
BankAccounts.openPlaidBankLogin(this.props.allowDebit, this.props.bankAccountID);
}

/**
* Get list of bank accounts
*
* @returns {Object[]}
*/
getPlaidBankAccounts() {
return lodashGet(this.props.plaidData, 'bankAccounts', []);
}

/**
* @returns {String}
*/
Expand All @@ -110,25 +104,13 @@ class AddPlaidBankAccount extends React.Component {
}
}

/**
* Triggered when user selects a Plaid bank account.
* @param {String} plaidAccountID
*/
selectAccount(plaidAccountID) {
const selectedPlaidBankAccount = _.findWhere(this.getPlaidBankAccounts(), {plaidAccountID});
selectedPlaidBankAccount.bankName = this.props.plaidData.bankName;
selectedPlaidBankAccount.plaidAccessToken = this.props.plaidData.plaidAccessToken;
this.props.onSelect({selectedPlaidBankAccount});
}

render() {
const plaidBankAccounts = this.getPlaidBankAccounts();
const plaidBankAccounts = lodashGet(this.props.plaidData, 'bankAccounts', []);
const token = this.getPlaidLinkToken();
const options = _.map(plaidBankAccounts, account => ({
value: account.plaidAccountID, label: `${account.addressName} ${account.mask}`,
value: account.plaidAccountID,
label: `${account.addressName} ${account.mask}`,
}));
const institutionName = lodashGet(this.props, 'plaidData.institution.name', '');
const selectedPlaidBankAccount = lodashGet(this.props, 'plaidData.selectedPlaidBankAccount', {});
const {icon, iconSize} = getBankIcon();

// Plaid Link view
Expand Down Expand Up @@ -180,18 +162,18 @@ class AddPlaidBankAccount extends React.Component {
height={iconSize}
width={iconSize}
/>
<Text style={[styles.ml3, styles.textStrong]}>{institutionName}</Text>
<Text style={[styles.ml3, styles.textStrong]}>{this.props.plaidData.bankName}</Text>
</View>
<View style={[styles.mb5]}>
<Picker
label={this.props.translate('addPersonalBankAccountPage.chooseAccountLabel')}
onInputChange={this.selectAccount}
onInputChange={this.props.onSelect}
items={options}
placeholder={_.isUndefined(this.props.plaidData.selectedPlaidBankAccount) ? {
placeholder={{
value: '',
label: this.props.translate('bankAccount.chooseAnAccount'),
} : {}}
value={selectedPlaidBankAccount.plaidAccountID}
}}
value={this.props.selectedPlaidAccountID}
/>
</View>
</View>
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/BankAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function addPersonalBankAccount(account, password) {
value: {
isLoading: true,
errors: null,
plaidAccountID: account.plaidAccountID,
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/PaymentMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function addPaymentCard(params) {
function clearDebitCardFormErrorAndSubmit() {
Onyx.set(ONYXKEYS.FORMS.ADD_DEBIT_CARD_FORM, {
isLoading: false,
error: null,
errors: null,
});
}

Expand Down
37 changes: 28 additions & 9 deletions src/pages/AddPersonalBankAccountPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,20 @@ import ROUTES from '../ROUTES';

const propTypes = {
...withLocalizePropTypes,

/** The details about the Personal bank account we are adding saved in Onyx */
personalBankAccount: PropTypes.shape({
/** An error message to display to the user */
error: PropTypes.string,

/** Whether we should show the view that the bank account was successfully added */
shouldShowSuccess: PropTypes.bool,

/** Whether the form is loading */
isLoading: PropTypes.bool,

/** The account ID of the selected bank account from Plaid */
plaidAccountID: PropTypes.string,
}),
};

Expand All @@ -39,6 +49,7 @@ const defaultProps = {
error: '',
shouldShowSuccess: false,
isLoading: false,
plaidAccountID: '',
},
};

Expand All @@ -50,7 +61,7 @@ class AddPersonalBankAccountPage extends React.Component {
this.submit = this.submit.bind(this);

this.state = {
selectedPlaidBankAccount: undefined,
selectedPlaidAccountID: this.props.personalBankAccount.plaidAccountID,
};
}

Expand All @@ -60,7 +71,8 @@ class AddPersonalBankAccountPage extends React.Component {

/**
* @param {Object} values - form input values passed by the Form component
* @returns {Ojbect}
* @param {Object} values.password The password of the user adding the bank account, for security.
* @returns {Object}
*/
validate(values) {
const errors = {};
Expand All @@ -74,9 +86,14 @@ class AddPersonalBankAccountPage extends React.Component {

/**
* @param {Object} values - form input values passed by the Form component
* @param {Object} values.password The password of the user adding the bank account, for security.
*/
submit(values) {
BankAccounts.addPersonalBankAccount(this.state.selectedPlaidBankAccount, values.password);
const selectedPlaidBankAccount = _.findWhere(lodashGet(this.props.plaidData, 'bankAccounts', []), {
plaidAccountID: this.state.selectedPlaidAccountID,
});

BankAccounts.addPersonalBankAccount(selectedPlaidBankAccount, values.password);
}

render() {
Expand Down Expand Up @@ -121,23 +138,22 @@ class AddPersonalBankAccountPage extends React.Component {
) : (
<Form
formID={ONYXKEYS.PERSONAL_BANK_ACCOUNT}
isSubmitButtonVisible={!_.isUndefined(this.state.selectedPlaidBankAccount)}
isSubmitButtonVisible={Boolean(this.state.selectedPlaidAccountID)}
submitButtonText={this.props.translate('common.saveAndContinue')}
onSubmit={this.submit}
validate={this.validate}
style={[styles.mh5, styles.flex1]}
>
<>
<AddPlaidBankAccount
onSelect={(params) => {
this.setState({
selectedPlaidBankAccount: params.selectedPlaidBankAccount,
});
onSelect={(selectedPlaidAccountID) => {
this.setState({selectedPlaidAccountID});
}}
onExitPlaid={Navigation.goBack}
receivedRedirectURI={getPlaidOAuthReceivedRedirectURI()}
selectedPlaidAccountID={this.state.selectedPlaidAccountID}
/>
{!_.isUndefined(this.state.selectedPlaidBankAccount) && (
{Boolean(this.state.selectedPlaidAccountID) && (
<TextInput
inputID="password"
label={this.props.translate('addPersonalBankAccountPage.enterPassword')}
Expand Down Expand Up @@ -165,5 +181,8 @@ export default compose(
personalBankAccount: {
key: ONYXKEYS.PERSONAL_BANK_ACCOUNT,
},
plaidData: {
key: ONYXKEYS.PLAID_DATA,
},
}),
)(AddPersonalBankAccountPage);
27 changes: 15 additions & 12 deletions src/pages/ReimbursementAccount/BankAccountPlaidStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from 'underscore';
import React from 'react';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import lodashGet from 'lodash/get';
import HeaderWithCloseButton from '../../components/HeaderWithCloseButton';
import CONST from '../../CONST';
import * as BankAccounts from '../../libs/actions/BankAccounts';
Expand Down Expand Up @@ -37,27 +38,28 @@ class BankAccountPlaidStep extends React.Component {
}

submit() {
const selectedPlaidBankAccount = this.props.plaidData.selectedPlaidBankAccount;
if (!selectedPlaidBankAccount) {
return;
}
const selectedPlaidBankAccount = _.findWhere(lodashGet(this.props.plaidData, 'bankAccounts', []), {
plaidAccountID: ReimbursementAccountUtils.getDefaultStateForField(this.props, 'plaidAccountID'),
});

ReimbursementAccount.updateReimbursementAccountDraft({
const bankAccountData = {
routingNumber: selectedPlaidBankAccount.routingNumber,
accountNumber: selectedPlaidBankAccount.accountNumber,
plaidMask: selectedPlaidBankAccount.mask,
isSavings: selectedPlaidBankAccount.isSavings,
bankName: selectedPlaidBankAccount.bankName,
bankName: this.props.plaidData.bankName,
plaidAccountID: selectedPlaidBankAccount.plaidAccountID,
plaidAccessToken: selectedPlaidBankAccount.plaidAccessToken,
});
plaidAccessToken: this.props.plaidData.plaidAccessToken,
};
ReimbursementAccount.updateReimbursementAccountDraft(bankAccountData);

const bankAccountID = ReimbursementAccountUtils.getDefaultStateForField(this.props, 'bankAccountID', 0);
BankAccounts.connectBankAccountWithPlaid(bankAccountID, selectedPlaidBankAccount);
BankAccounts.connectBankAccountWithPlaid(bankAccountID, bankAccountData);
}

render() {
const bankAccountID = ReimbursementAccountUtils.getDefaultStateForField(this.props, 'bankAccountID', 0);
const selectedPlaidAccountID = ReimbursementAccountUtils.getDefaultStateForField(this.props, 'plaidAccountID', '');

return (
<>
Expand All @@ -76,18 +78,19 @@ class BankAccountPlaidStep extends React.Component {
onSubmit={this.submit}
submitButtonText={this.props.translate('common.saveAndContinue')}
style={[styles.mh5, styles.flexGrow1]}
isSubmitButtonVisible={!_.isUndefined(this.props.plaidData.selectedPlaidBankAccount)}
isSubmitButtonVisible={Boolean(selectedPlaidAccountID)}
>
<AddPlaidBankAccount
text={this.props.translate('bankAccount.plaidBodyCopy')}
onSelect={(params) => {
BankAccounts.updatePlaidData({selectedPlaidBankAccount: params.selectedPlaidBankAccount});
onSelect={(plaidAccountID) => {
ReimbursementAccount.updateReimbursementAccountDraft({plaidAccountID});
}}
onExitPlaid={() => BankAccounts.setBankAccountSubStep(null)}
receivedRedirectURI={this.props.receivedRedirectURI}
plaidLinkOAuthToken={this.props.plaidLinkOAuthToken}
allowDebit
bankAccountID={bankAccountID}
selectedPlaidAccountID={selectedPlaidAccountID}
/>
</Form>
</>
Expand Down
12 changes: 11 additions & 1 deletion src/pages/ReimbursementAccount/BankAccountStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ import getPlaidDesktopMessage from '../../libs/getPlaidDesktopMessage';
import CONFIG from '../../CONFIG';
import ROUTES from '../../ROUTES';
import Button from '../../components/Button';
import plaidDataPropTypes from './plaidDataPropTypes';

const propTypes = {
/** Contains plaid data */
plaidData: plaidDataPropTypes,

/** The OAuth URI + stateID needed to re-initialize the PlaidLink after the user logs into their bank */
receivedRedirectURI: PropTypes.string,

Expand All @@ -45,6 +49,9 @@ const propTypes = {
const defaultProps = {
receivedRedirectURI: null,
plaidLinkOAuthToken: '',
plaidData: {
isPlaidDisabled: false,
},
user: {},
};

Expand Down Expand Up @@ -105,7 +112,7 @@ const BankAccountStep = (props) => {
BankAccounts.clearPlaid();
BankAccounts.setBankAccountSubStep(CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID);
}}
disabled={props.isPlaidDisabled || !props.user.validated}
disabled={props.plaidData.isPlaidDisabled || !props.user.validated}
style={[styles.mt5, styles.buttonCTA]}
iconStyles={[styles.buttonCTAIcon]}
shouldShowRightIcon
Expand Down Expand Up @@ -168,5 +175,8 @@ export default compose(
reimbursementAccount: {
key: ONYXKEYS.REIMBURSEMENT_ACCOUNT,
},
plaidData: {
key: ONYXKEYS.PLAID_DATA,
},
}),
)(BankAccountStep);
Loading