diff --git a/src/libs/LoginUtils.ts b/src/libs/LoginUtils.ts index 8ee6d94952f8..2d49cb992717 100644 --- a/src/libs/LoginUtils.ts +++ b/src/libs/LoginUtils.ts @@ -40,7 +40,7 @@ function isEmailPublicDomain(email: string): boolean { function validateNumber(values: string): string { const parsedPhoneNumber = parsePhoneNumber(values); - if (parsedPhoneNumber.possible && Str.isValidPhone(values.slice(0))) { + if (parsedPhoneNumber.possible && Str.isValidE164Phone(values.slice(0))) { return `${parsedPhoneNumber.number?.e164}${CONST.SMS.DOMAIN}`; } diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 9e1320e83abb..8508f5c284d5 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1695,7 +1695,7 @@ function getOptions( !isCurrentUser({login: searchValue} as PersonalDetails) && selectedOptions.every((option) => 'login' in option && option.login !== searchValue) && ((Str.isValidEmail(searchValue) && !Str.isDomainEmail(searchValue) && !Str.endsWith(searchValue, CONST.SMS.DOMAIN)) || - (parsedPhoneNumber.possible && Str.isValidPhone(LoginUtils.getPhoneNumberWithoutSpecialChars(parsedPhoneNumber.number?.input ?? '')))) && + (parsedPhoneNumber.possible && Str.isValidE164Phone(LoginUtils.getPhoneNumberWithoutSpecialChars(parsedPhoneNumber.number?.input ?? '')))) && !optionsToExclude.find((optionToExclude) => 'login' in optionToExclude && optionToExclude.login === PhoneNumber.addSMSDomainIfPhoneNumber(searchValue).toLowerCase()) && (searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas)) && !excludeUnknownUsers diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 96c685d4185a..3e12a2db08d2 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3036,7 +3036,7 @@ function getParsedComment(text: string): string { return `@${mentionWithEmailDomain}`; } } - if (Str.isValidPhone(mention)) { + if (Str.isValidE164Phone(mention)) { const mentionWithSmsDomain = PhoneNumber.addSMSDomainIfPhoneNumber(mention); if (allPersonalDetailLogins.includes(mentionWithSmsDomain)) { return `@${mentionWithSmsDomain}`; diff --git a/src/libs/UserUtils.ts b/src/libs/UserUtils.ts index 147343e99ceb..ce7e4963afc7 100644 --- a/src/libs/UserUtils.ts +++ b/src/libs/UserUtils.ts @@ -210,7 +210,7 @@ function getSmallSizeAvatar(avatarSource: AvatarSource, accountID?: number): Ava */ function getSecondaryPhoneLogin(loginList: OnyxEntry): string | undefined { const parsedLoginList = Object.keys(loginList ?? {}).map((login) => Str.removeSMSDomain(login)); - return parsedLoginList.find((login) => Str.isValidPhone(login)); + return parsedLoginList.find((login) => Str.isValidE164Phone(login)); } export { diff --git a/src/libs/ValidationUtils.ts b/src/libs/ValidationUtils.ts index cacab8333868..b1f6085f4538 100644 --- a/src/libs/ValidationUtils.ts +++ b/src/libs/ValidationUtils.ts @@ -284,7 +284,7 @@ function isValidUSPhone(phoneNumber = '', isCountryCodeOptional?: boolean): bool // When we pass regionCode as an option to parsePhoneNumber it wrongly assumes inputs like '=15123456789' as valid // so we need to check if it is a valid phone. - if (regionCode && !Str.isValidPhone(phone)) { + if (regionCode && !Str.isValidPhoneFormat(phone)) { return false; }