Skip to content

Commit f6b41a3

Browse files
authored
Merge pull request #4261 from Expensify/jasper-fixBoldTextExistingOwnersError
Fix bolded text for Existing Owners Error
2 parents d971a64 + b1c6da3 commit f6b41a3

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

src/libs/actions/BankAccounts.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -618,18 +618,12 @@ function setupWithdrawalAccount(data) {
618618
// Show warning if another account already set up this bank account and promote share
619619
if (response.existingOwners) {
620620
console.error('Cannot set up withdrawal account due to existing owners', response);
621-
const existingOwnersList = response.existingOwners.reduce((ownersStr, owner, i, ownersArr) => {
622-
let separator = ',\n';
623-
if (i === 0) {
624-
separator = '\n';
625-
} else if (i === ownersArr.length - 1) {
626-
separator = ' and\n';
627-
}
628-
return `${ownersStr}${separator}${owner}`;
629-
}, '');
630621
Onyx.merge(
631622
ONYXKEYS.REIMBURSEMENT_ACCOUNT,
632-
{existingOwnersList, error: CONST.BANK_ACCOUNT.ERROR.EXISTING_OWNERS},
623+
{
624+
existingOwners: response.existingOwners,
625+
error: CONST.BANK_ACCOUNT.ERROR.EXISTING_OWNERS,
626+
},
633627
);
634628
return;
635629
}

src/pages/ReimbursementAccount/BankAccountStep.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ const propTypes = {
3636
/** Error set when handling the API response */
3737
error: PropTypes.string,
3838

39-
/** A list of existing owners, set if the bank account being added is already owned */
40-
existingOwnersList: PropTypes.string,
39+
/** The existing owners for if the bank account is already owned */
40+
existingOwners: PropTypes.arrayOf(PropTypes.string),
4141
}).isRequired,
4242

4343
...withLocalizePropTypes,
@@ -129,8 +129,9 @@ class BankAccountStep extends React.Component {
129129
// Disable bank account fields once they've been added in db so they can't be changed
130130
const isFromPlaid = this.props.achData.setupType === CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID;
131131
const shouldDisableInputs = Boolean(this.props.achData.bankAccountID) || isFromPlaid;
132+
const existingOwners = this.props.reimbursementAccount.existingOwners;
132133
const isExistingOwnersErrorVisible = Boolean(this.props.reimbursementAccount.error
133-
&& this.props.reimbursementAccount.existingOwnersList);
134+
&& existingOwners);
134135
return (
135136
<View style={[styles.flex1, styles.justifyContentBetween]}>
136137
<HeaderWithCloseButton
@@ -252,14 +253,26 @@ class BankAccountStep extends React.Component {
252253
onConfirm={hideExistingOwnersError}
253254
shouldShowCancelButton={false}
254255
prompt={(
255-
<View style={[styles.flex1]}>
256+
<View>
256257
<Text style={[styles.mb4]}>
257258
<Text>
258259
{this.props.translate('bankAccount.error.existingOwners.alreadyInUse')}
259260
</Text>
260-
<Text style={styles.textStrong}>
261-
{this.props.reimbursementAccount.existingOwnersList}
262-
</Text>
261+
{existingOwners && existingOwners.map((existingOwner, i) => {
262+
let separator = ', ';
263+
if (i === 0) {
264+
separator = '';
265+
} else if (i === existingOwners.length - 1) {
266+
separator = ` ${this.props.translate('common.and')} `;
267+
}
268+
return (
269+
<>
270+
<Text>{separator}</Text>
271+
<Text style={styles.textStrong}>{existingOwner}</Text>
272+
{i === existingOwners.length - 1 && <Text>.</Text>}
273+
</>
274+
);
275+
})}
263276
</Text>
264277
<Text style={[styles.mb4]}>
265278
{this.props.translate('bankAccount.error.existingOwners.pleaseAskThemToShare')}

0 commit comments

Comments
 (0)