From 12227cb8bd9d80a2f93df741086ef2ea550e84a6 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 8 Jan 2024 10:50:33 +0700 Subject: [PATCH 1/3] replace all spaces before compare with search text in workspace invite --- src/pages/workspace/WorkspaceInvitePage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceInvitePage.js b/src/pages/workspace/WorkspaceInvitePage.js index 589c4971506b..166372fc291d 100644 --- a/src/pages/workspace/WorkspaceInvitePage.js +++ b/src/pages/workspace/WorkspaceInvitePage.js @@ -142,7 +142,7 @@ function WorkspaceInvitePage(props) { const accountID = lodashGet(option, 'accountID', null); const isOptionInPersonalDetails = _.some(personalDetails, (personalDetail) => personalDetail.accountID === accountID); - const isPartOfSearchTerm = option.text.toLowerCase().includes(searchTerm.trim().toLowerCase()); + const isPartOfSearchTerm = option.text.replaceAll(' ','').toLowerCase().includes(searchTerm.trim().toLowerCase()); return isPartOfSearchTerm || isOptionInPersonalDetails; }); } From 75cf69e2f80d65bd8e0dfe03d85d676e0bfce3a8 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 8 Jan 2024 15:47:56 +0700 Subject: [PATCH 2/3] refactor search logic --- src/pages/workspace/WorkspaceInvitePage.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceInvitePage.js b/src/pages/workspace/WorkspaceInvitePage.js index 166372fc291d..9e1a26e25dcc 100644 --- a/src/pages/workspace/WorkspaceInvitePage.js +++ b/src/pages/workspace/WorkspaceInvitePage.js @@ -1,3 +1,5 @@ +import {parsePhoneNumber} from 'awesome-phonenumber'; +import Str from 'expensify-common/lib/str'; import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; import React, {useEffect, useMemo, useState} from 'react'; @@ -14,6 +16,7 @@ import useNetwork from '@hooks/useNetwork'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Browser from '@libs/Browser'; import compose from '@libs/compose'; +import * as LoginUtils from '@libs/LoginUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PolicyUtils from '@libs/PolicyUtils'; @@ -141,8 +144,10 @@ function WorkspaceInvitePage(props) { filterSelectedOptions = _.filter(selectedOptions, (option) => { const accountID = lodashGet(option, 'accountID', null); const isOptionInPersonalDetails = _.some(personalDetails, (personalDetail) => personalDetail.accountID === accountID); + const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); + const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number.e164 : searchTerm.toLowerCase(); - const isPartOfSearchTerm = option.text.replaceAll(' ','').toLowerCase().includes(searchTerm.trim().toLowerCase()); + const isPartOfSearchTerm = option.text.toLowerCase().includes(searchValue) || option.login.toLowerCase().includes(searchValue); return isPartOfSearchTerm || isOptionInPersonalDetails; }); } From 902d857914d67b1a7b99d013252391ac2af91bb2 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Mon, 8 Jan 2024 16:34:00 +0700 Subject: [PATCH 3/3] refactor search logic --- src/pages/RoomInvitePage.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pages/RoomInvitePage.js b/src/pages/RoomInvitePage.js index f8d2d32bfe79..ff2997c67f37 100644 --- a/src/pages/RoomInvitePage.js +++ b/src/pages/RoomInvitePage.js @@ -1,3 +1,5 @@ +import {parsePhoneNumber} from 'awesome-phonenumber'; +import Str from 'expensify-common/lib/str'; import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; import React, {useCallback, useEffect, useMemo, useState} from 'react'; @@ -13,6 +15,7 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Browser from '@libs/Browser'; import compose from '@libs/compose'; +import * as LoginUtils from '@libs/LoginUtils'; import Navigation from '@libs/Navigation/Navigation'; import * as OptionsListUtils from '@libs/OptionsListUtils'; import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; @@ -102,8 +105,9 @@ function RoomInvitePage(props) { filterSelectedOptions = _.filter(selectedOptions, (option) => { const accountID = lodashGet(option, 'accountID', null); const isOptionInPersonalDetails = _.some(personalDetails, (personalDetail) => personalDetail.accountID === accountID); - - const isPartOfSearchTerm = option.text.toLowerCase().includes(searchTerm.trim().toLowerCase()); + const parsedPhoneNumber = parsePhoneNumber(LoginUtils.appendCountryCode(Str.removeSMSDomain(searchTerm))); + const searchValue = parsedPhoneNumber.possible ? parsedPhoneNumber.number.e164 : searchTerm.toLowerCase(); + const isPartOfSearchTerm = option.text.toLowerCase().includes(searchValue) || option.login.toLowerCase().includes(searchValue); return isPartOfSearchTerm || isOptionInPersonalDetails; }); }