Skip to content

Commit

Permalink
Merge pull request #23366 from GItGudRatio/fix/22521-fix-alphabet-num…
Browse files Browse the repository at this point in the history
…ber-search

Fix text based mobile search on InviteMembers page
  • Loading branch information
amyevans authored Jul 24, 2023
2 parents a656c82 + 0632292 commit 2c15e97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,8 @@ function getOptions(
(noOptions || noOptionsMatchExactly) &&
!isCurrentUser({login: searchValue}) &&
_.every(selectedOptions, (option) => option.login !== searchValue) &&
((Str.isValidEmail(searchValue) && !Str.isDomainEmail(searchValue) && !Str.endsWith(searchValue, CONST.SMS.DOMAIN)) || parsedPhoneNumber.possible) &&
((Str.isValidEmail(searchValue) && !Str.isDomainEmail(searchValue) && !Str.endsWith(searchValue, CONST.SMS.DOMAIN)) ||
(parsedPhoneNumber.possible && Str.isValidPhone(LoginUtils.getPhoneNumberWithoutSpecialChars(parsedPhoneNumber.number.input)))) &&
!_.find(loginOptionsToExclude, (loginOptionToExclude) => loginOptionToExclude.login === addSMSDomainIfPhoneNumber(searchValue).toLowerCase()) &&
(searchValue !== CONST.EMAIL.CHRONOS || Permissions.canUseChronos(betas))
) {
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/OptionsListUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,14 @@ describe('OptionsListUtils', () => {
expect(results.userToInvite).not.toBe(null);
expect(results.userToInvite.login).toBe('+18003243233');

// When we use a search term for contact number that contains alphabet characters
results = OptionsListUtils.getNewChatOptions(REPORTS, PERSONAL_DETAILS, [], '998243aaaa');

// Then we shouldn't have any results or user to invite
expect(results.recentReports.length).toBe(0);
expect(results.personalDetails.length).toBe(0);
expect(results.userToInvite).toBe(null);

// Test Concierge's existence in new group options
results = OptionsListUtils.getNewChatOptions(REPORTS_WITH_CONCIERGE, PERSONAL_DETAILS_WITH_CONCIERGE);

Expand Down

0 comments on commit 2c15e97

Please sign in to comment.