From 0ff0eee319b258bb81565cd9ea11ce3cabc07a05 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 3 Nov 2023 11:14:40 +0700 Subject: [PATCH 1/3] fix account number regex condition --- src/CONST.ts | 1 + src/pages/ReimbursementAccount/BankAccountManualStep.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index 29bb0b83aaee..a0839cf878a1 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -218,6 +218,7 @@ const CONST = { // 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}$/, + MASKED_US_ACCOUNT_NUMBER_MATCH_BE: /^[X]{0,13}[0-9]{4}$/, // we can change the name later 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 13155d286a5e..9c7b64efce90 100644 --- a/src/pages/ReimbursementAccount/BankAccountManualStep.js +++ b/src/pages/ReimbursementAccount/BankAccountManualStep.js @@ -40,7 +40,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_MATCH_BE.test(values.accountNumber.trim())) ) { errors.accountNumber = 'bankAccount.error.accountNumber'; } else if (values.accountNumber && values.accountNumber === routingNumber) { From 87b0d782b24a86b5390f4570d4b3ef84701d3e0b Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Fri, 3 Nov 2023 11:28:48 +0700 Subject: [PATCH 2/3] fix lint error --- src/pages/ReimbursementAccount/BankAccountManualStep.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/ReimbursementAccount/BankAccountManualStep.js b/src/pages/ReimbursementAccount/BankAccountManualStep.js index 9c7b64efce90..dbd169dfacb0 100644 --- a/src/pages/ReimbursementAccount/BankAccountManualStep.js +++ b/src/pages/ReimbursementAccount/BankAccountManualStep.js @@ -27,6 +27,9 @@ const propTypes = { function BankAccountManualStep(props) { 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} @@ -55,7 +58,7 @@ function BankAccountManualStep(props) { return errors; }, - [translate], + [translate, shouldDisableInputs], ); const submit = useCallback( @@ -70,8 +73,6 @@ function BankAccountManualStep(props) { [reimbursementAccount, reimbursementAccountDraft], ); - const shouldDisableInputs = Boolean(lodashGet(reimbursementAccount, 'achData.bankAccountID')); - return ( Date: Fri, 10 Nov 2023 14:56:11 +0700 Subject: [PATCH 3/3] update front-end masked account number --- src/CONST.ts | 6 ++---- src/pages/ReimbursementAccount/BankAccountManualStep.js | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 3cef18c59b76..6b0c5b2214ac 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -218,10 +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}$/, - MASKED_US_ACCOUNT_NUMBER_MATCH_BE: /^[X]{0,13}[0-9]{4}$/, // we can change the name later + // 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 c72be8b62568..d15fcb2a7adf 100644 --- a/src/pages/ReimbursementAccount/BankAccountManualStep.js +++ b/src/pages/ReimbursementAccount/BankAccountManualStep.js @@ -43,7 +43,7 @@ function BankAccountManualStep(props) { if ( values.accountNumber && !CONST.BANK_ACCOUNT.REGEX.US_ACCOUNT_NUMBER.test(values.accountNumber.trim()) && - !(shouldDisableInputs && CONST.BANK_ACCOUNT.REGEX.MASKED_US_ACCOUNT_NUMBER_MATCH_BE.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) {