diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index a32d86ccb510..61de076d9382 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -575,18 +575,19 @@ function getOptions(reports, personalDetails, { let userToInvite = null; const noOptions = (recentReportOptions.length + personalDetailsOptions.length) === 0; const noOptionsMatchExactly = !_.find(personalDetailsOptions.concat(recentReportOptions), option => option.login === searchValue.toLowerCase()); - if (searchValue && (noOptions || noOptionsMatchExactly) - && !isCurrentUser({login: searchValue}) - && _.every(selectedOptions, option => option.login !== searchValue) - && ((Str.isValidEmail(searchValue) && !Str.isDomainEmail(searchValue)) || Str.isValidPhone(searchValue)) - && (!_.find(loginOptionsToExclude, loginOptionToExclude => loginOptionToExclude.login === addSMSDomainIfPhoneNumber(searchValue).toLowerCase())) - && (searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas)) + + // If the phone number doesn't have an international code then let's prefix it with the + // current user's international code based on their IP address. + const login = (Str.isValidPhone(searchValue) && !searchValue.includes('+')) + ? `+${countryCodeByIP}${searchValue}` + : searchValue; + if (login && (noOptions || noOptionsMatchExactly) + && !isCurrentUser({login}) + && _.every(selectedOptions, option => option.login !== login) + && ((Str.isValidEmail(login) && !Str.isDomainEmail(login)) || Str.isValidPhone(login)) + && (!_.find(loginOptionsToExclude, loginOptionToExclude => loginOptionToExclude.login === addSMSDomainIfPhoneNumber(login).toLowerCase())) + && (login !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas)) ) { - // If the phone number doesn't have an international code then let's prefix it with the - // current user's international code based on their IP address. - const login = (Str.isValidPhone(searchValue) && !searchValue.includes('+')) - ? `+${countryCodeByIP}${searchValue}` - : searchValue; userToInvite = createOption([login], personalDetails, null, reportActions, { showChatPreviewLine, });