Skip to content

Commit

Permalink
Merge pull request #30813 from dukenv0307/fix/30686
Browse files Browse the repository at this point in the history
Fix Update regex for masked accountNumber
  • Loading branch information
lakchote authored Nov 20, 2023
2 parents e79d5c7 + 3baf085 commit 959a6d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions src/pages/ReimbursementAccount/BankAccountManualStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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) {
Expand All @@ -56,7 +59,7 @@ function BankAccountManualStep(props) {

return errors;
},
[translate],
[translate, shouldDisableInputs],
);

const submit = useCallback(
Expand All @@ -71,8 +74,6 @@ function BankAccountManualStep(props) {
[reimbursementAccount, reimbursementAccountDraft],
);

const shouldDisableInputs = Boolean(lodashGet(reimbursementAccount, 'achData.bankAccountID'));

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down

0 comments on commit 959a6d9

Please sign in to comment.