diff --git a/src/CONST.ts b/src/CONST.ts index 709e9d3bafe2..b43d75e5cb80 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -218,9 +218,8 @@ const CONST = { REGEX: { US_ACCOUNT_NUMBER: /^[0-9]{4,17}$/, - // If the account number length is from 4 to 13 digits, we show the last 4 digits and hide the rest with X - // If the length is longer than 13 digits, we show the first 6 and last 4 digits, hiding the rest with X - MASKED_US_ACCOUNT_NUMBER: /^[X]{0,9}[0-9]{4}$|^[0-9]{6}[X]{4,7}[0-9]{4}$/, + // The back-end is always returning account number with 4 last digits and mask the rest with X + MASKED_US_ACCOUNT_NUMBER: /^[X]{0,13}[0-9]{4}$/, SWIFT_BIC: /^[A-Za-z0-9]{8,11}$/, }, VERIFICATION_MAX_ATTEMPTS: 7, diff --git a/src/pages/ReimbursementAccount/BankAccountManualStep.js b/src/pages/ReimbursementAccount/BankAccountManualStep.js index dd541c68ecf4..b46d3aa0aa28 100644 --- a/src/pages/ReimbursementAccount/BankAccountManualStep.js +++ b/src/pages/ReimbursementAccount/BankAccountManualStep.js @@ -28,6 +28,9 @@ function BankAccountManualStep(props) { const styles = useThemeStyles(); const {translate, preferredLocale} = useLocalize(); const {reimbursementAccount, reimbursementAccountDraft} = props; + + const shouldDisableInputs = Boolean(lodashGet(reimbursementAccount, 'achData.bankAccountID')); + /** * @param {Object} values - form input values passed by the Form component * @returns {Object} @@ -41,7 +44,7 @@ function BankAccountManualStep(props) { if ( values.accountNumber && !CONST.BANK_ACCOUNT.REGEX.US_ACCOUNT_NUMBER.test(values.accountNumber.trim()) && - !CONST.BANK_ACCOUNT.REGEX.MASKED_US_ACCOUNT_NUMBER.test(values.accountNumber.trim()) + !(shouldDisableInputs && CONST.BANK_ACCOUNT.REGEX.MASKED_US_ACCOUNT_NUMBER.test(values.accountNumber.trim())) ) { errors.accountNumber = 'bankAccount.error.accountNumber'; } else if (values.accountNumber && values.accountNumber === routingNumber) { @@ -56,7 +59,7 @@ function BankAccountManualStep(props) { return errors; }, - [translate], + [translate, shouldDisableInputs], ); const submit = useCallback( @@ -71,8 +74,6 @@ function BankAccountManualStep(props) { [reimbursementAccount, reimbursementAccountDraft], ); - const shouldDisableInputs = Boolean(lodashGet(reimbursementAccount, 'achData.bankAccountID')); - return (