Skip to content
7 changes: 5 additions & 2 deletions src/components/WorkspaceMembersSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {useMemo} from 'react';
import type {SectionListData} from 'react-native';
import useDebouncedState from '@hooks/useDebouncedState';
import useLocalize from '@hooks/useLocalize';
import useOnyx from '@hooks/useOnyx';
import usePolicy from '@hooks/usePolicy';
import useScreenWrapperTransitionStatus from '@hooks/useScreenWrapperTransitionStatus';
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
Expand All @@ -10,6 +11,7 @@ import {getMemberAccountIDsForWorkspace} from '@libs/PolicyUtils';
import tokenizedSearch from '@libs/tokenizedSearch';
import MemberRightIcon from '@pages/workspace/MemberRightIcon';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Icon} from '@src/types/onyx/OnyxCommon';
import {FallbackAvatar} from './Icon/Expensicons';
import {usePersonalDetails} from './OnyxListItemProvider';
Expand Down Expand Up @@ -40,6 +42,7 @@ function WorkspaceMembersSelectionList({policyID, selectedApprover, setApprover}
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
const personalDetails = usePersonalDetails();
const policy = usePolicy(policyID);
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});

const sections: ApproverSection[] = useMemo(() => {
const approvers: SelectionListApprover[] = [];
Expand Down Expand Up @@ -78,7 +81,7 @@ function WorkspaceMembersSelectionList({policyID, selectedApprover, setApprover}
approvers.push(...availableApprovers);
}

const filteredApprovers = tokenizedSearch(approvers, getSearchValueForPhoneOrEmail(debouncedSearchTerm), (approver) => [approver.text ?? '', approver.login ?? '']);
const filteredApprovers = tokenizedSearch(approvers, getSearchValueForPhoneOrEmail(debouncedSearchTerm, countryCode), (approver) => [approver.text ?? '', approver.login ?? '']);

return [
{
Expand All @@ -87,7 +90,7 @@ function WorkspaceMembersSelectionList({policyID, selectedApprover, setApprover}
shouldShow: true,
},
];
}, [debouncedSearchTerm, personalDetails, policy?.employeeList, policy?.owner, selectedApprover, localeCompare]);
}, [policy?.employeeList, policy?.owner, debouncedSearchTerm, countryCode, localeCompare, personalDetails, selectedApprover]);

const handleOnSelectRow = (approver: SelectionListApprover) => {
setApprover(approver.login);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/LoginUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import {parsePhoneNumber} from './PhoneNumber';

let countryCodeByIPOnyx: number;
Onyx.connect({

Check warning on line 12 in src/libs/LoginUtils.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function

Check warning on line 12 in src/libs/LoginUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COUNTRY_CODE,
callback: (val) => (countryCodeByIPOnyx = val ?? 1),
});
Expand Down Expand Up @@ -55,7 +55,7 @@
*
* TODO: Remove this function after completing Onyx.connect deprecation (issue #66329)
*/
function appendCountryCodeWithCountryCode(phone: string, countryCode: string): string {
function appendCountryCodeWithCountryCode(phone: string, countryCode: number): string {
if (phone.startsWith('+')) {
return phone;
}
Expand Down
6 changes: 3 additions & 3 deletions src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import {isReportMessageAttachment} from '@libs/isReportMessageAttachment';
import {formatPhoneNumber} from '@libs/LocalePhoneNumber';
import {translateLocal} from '@libs/Localize';
import {appendCountryCode, getPhoneNumberWithoutSpecialChars} from '@libs/LoginUtils';
import {appendCountryCode, appendCountryCodeWithCountryCode, getPhoneNumberWithoutSpecialChars} from '@libs/LoginUtils';
import {MaxHeap} from '@libs/MaxHeap';
import {MinHeap} from '@libs/MinHeap';
import ModifiedExpenseMessage from '@libs/ModifiedExpenseMessage';
Expand Down Expand Up @@ -183,7 +183,7 @@
*/
let currentUserLogin: string | undefined;
let currentUserAccountID: number | undefined;
Onyx.connect({

Check warning on line 186 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
currentUserLogin = value?.email;
Expand All @@ -192,19 +192,19 @@
});

let loginList: OnyxEntry<Login>;
Onyx.connect({

Check warning on line 195 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.LOGIN_LIST,
callback: (value) => (loginList = isEmptyObject(value) ? {} : value),
});

let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
Onyx.connect({

Check warning on line 201 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => (allPersonalDetails = isEmptyObject(value) ? {} : value),
});

const policies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 207 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
callback: (policy, key) => {
if (!policy || !key || !policy.name) {
Expand All @@ -216,14 +216,14 @@
});

let allPolicies: OnyxCollection<Policy> = {};
Onyx.connect({

Check warning on line 219 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (val) => (allPolicies = val),
});

let allReports: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 226 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -232,7 +232,7 @@
});

let allReportNameValuePairs: OnyxCollection<ReportNameValuePairs>;
Onyx.connect({

Check warning on line 235 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -244,7 +244,7 @@
const allSortedReportActions: Record<string, ReportAction[]> = {};
let allReportActions: OnyxCollection<ReportActions>;
const lastVisibleReportActions: ReportActions = {};
Onyx.connect({

Check warning on line 247 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -303,7 +303,7 @@
});

let activePolicyID: OnyxEntry<string>;
Onyx.connect({

Check warning on line 306 in src/libs/OptionsListUtils/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.NVP_ACTIVE_POLICY_ID,
callback: (value) => (activePolicyID = value),
});
Expand Down Expand Up @@ -1019,8 +1019,8 @@
return false;
}

function getSearchValueForPhoneOrEmail(searchTerm: string) {
const parsedPhoneNumber = parsePhoneNumber(appendCountryCode(Str.removeSMSDomain(searchTerm)));
function getSearchValueForPhoneOrEmail(searchTerm: string, countryCode: OnyxEntry<number>) {
const parsedPhoneNumber = parsePhoneNumber(appendCountryCodeWithCountryCode(Str.removeSMSDomain(searchTerm), countryCode ?? 1));
return parsedPhoneNumber.possible ? (parsedPhoneNumber.number?.e164 ?? '') : searchTerm.toLowerCase();
}

Expand Down
5 changes: 3 additions & 2 deletions src/pages/InviteReportParticipantsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ type Sections = Array<SectionListData<MemberForList, Section<MemberForList>>>;

function InviteReportParticipantsPage({betas, report, didScreenTransitionEnd}: InviteReportParticipantsPageProps) {
const route = useRoute<PlatformStackRouteProp<ParticipantsNavigatorParamList, typeof SCREENS.REPORT_PARTICIPANTS.INVITE>>();
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});
const {options, areOptionsInitialized} = useOptionsList({
shouldInitialize: didScreenTransitionEnd,
});
Expand Down Expand Up @@ -117,7 +118,7 @@ function InviteReportParticipantsPage({betas, report, didScreenTransitionEnd}: I
// Filter all options that is a part of the search term or in the personal details
let filterSelectedOptions = selectedOptions;
if (debouncedSearchTerm !== '') {
const processedSearchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm);
const processedSearchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm, countryCode);
filterSelectedOptions = tokenizedSearch(selectedOptions, processedSearchValue, (option) => [option.text ?? '', option.login ?? '']).filter((option) => {
const accountID = option?.accountID;
const isOptionInPersonalDetails = inviteOptions.personalDetails.some((personalDetail) => accountID && personalDetail?.accountID === accountID);
Expand Down Expand Up @@ -158,7 +159,7 @@ function InviteReportParticipantsPage({betas, report, didScreenTransitionEnd}: I
}

return sectionsArr;
}, [areOptionsInitialized, selectedOptions, debouncedSearchTerm, inviteOptions.recentReports, inviteOptions.personalDetails, inviteOptions.userToInvite, translate]);
}, [areOptionsInitialized, selectedOptions, debouncedSearchTerm, inviteOptions.recentReports, inviteOptions.personalDetails, inviteOptions.userToInvite, translate, countryCode]);

const toggleOption = useCallback(
(option: MemberForList) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWo
const [didScreenTransitionEnd, setDidScreenTransitionEnd] = useState(false);
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {canBeMissing: true, initWithStoredValues: false});
const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false});
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const session = useSession();
const {isBetaEnabled} = usePermissions();
Expand Down Expand Up @@ -164,7 +165,7 @@ function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWo
const accountID = option.accountID;
const isOptionInPersonalDetails = Object.values(personalDetails).some((personalDetail) => personalDetail.accountID === accountID);

const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm);
const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm, countryCode);

const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue);
return isPartOfSearchTerm || isOptionInPersonalDetails;
Expand Down Expand Up @@ -202,7 +203,7 @@ function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWo
});

return sectionsArr;
}, [areOptionsInitialized, selectedOptions, debouncedSearchTerm, personalDetails, translate, usersToInvite]);
}, [areOptionsInitialized, selectedOptions, debouncedSearchTerm, personalDetails, translate, usersToInvite, countryCode]);

const toggleOption = (option: MemberForList) => {
const isOptionInList = selectedOptions.some((selectedOption) => selectedOption.login === option.login);
Expand Down
11 changes: 6 additions & 5 deletions src/pages/workspace/WorkspaceInvitePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ function WorkspaceInvitePage({route, policy}: WorkspaceInvitePageProps) {
const [personalDetails, setPersonalDetails] = useState<OptionData[]>([]);
const [usersToInvite, setUsersToInvite] = useState<OptionData[]>([]);
const [didScreenTransitionEnd, setDidScreenTransitionEnd] = useState(false);
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false});
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false, canBeMissing: true});
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});
const firstRenderRef = useRef(true);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [invitedEmailsToAccountIDsDraft] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`);
const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false});
const [invitedEmailsToAccountIDsDraft] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`, {canBeMissing: true});

const openWorkspaceInvitePage = () => {
const policyMemberEmailsToAccountIDs = getMemberAccountIDsForWorkspace(policy?.employeeList);
Expand Down Expand Up @@ -177,7 +178,7 @@ function WorkspaceInvitePage({route, policy}: WorkspaceInvitePageProps) {
const accountID = option.accountID;
const isOptionInPersonalDetails = Object.values(personalDetails).some((personalDetail) => personalDetail.accountID === accountID);

const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm);
const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm, countryCode);

const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue);
return isPartOfSearchTerm || isOptionInPersonalDetails;
Expand Down Expand Up @@ -214,7 +215,7 @@ function WorkspaceInvitePage({route, policy}: WorkspaceInvitePageProps) {
});

return sectionsArr;
}, [areOptionsInitialized, selectedOptions, debouncedSearchTerm, personalDetails, translate, usersToInvite]);
}, [areOptionsInitialized, selectedOptions, debouncedSearchTerm, personalDetails, translate, usersToInvite, countryCode]);

const toggleOption = (option: MemberForList) => {
clearErrors(route.params.policyID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function AssigneeStep({policy, feed}: AssigneeStepProps) {
const {isOffline} = useNetwork();
const [assignCard] = useOnyx(ONYXKEYS.ASSIGN_CARD, {canBeMissing: true});
const [workspaceCardFeeds] = useOnyx(ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST, {canBeMissing: false});
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});
const [list] = useCardsList(policy?.id, feed);
const [cardFeeds] = useCardFeeds(policy?.id);
const filteredCardList = getFilteredCardList(list, cardFeeds?.settings?.oAuthAccountDetails?.[feed], workspaceCardFeeds);
Expand Down Expand Up @@ -153,7 +154,7 @@ function AssigneeStep({policy, feed}: AssigneeStepProps) {
];
}

const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm).toLowerCase();
const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm, countryCode).toLowerCase();
const filteredOptions = tokenizedSearch(membersDetails, searchValue, (option) => [option.text ?? '', option.alternateText ?? '']);

return [
Expand All @@ -163,7 +164,7 @@ function AssigneeStep({policy, feed}: AssigneeStepProps) {
shouldShow: true,
},
];
}, [membersDetails, debouncedSearchTerm]);
}, [membersDetails, debouncedSearchTerm, countryCode]);

const headerMessage = useMemo(() => {
const searchValue = debouncedSearchTerm.trim().toLowerCase();
Expand Down
5 changes: 3 additions & 2 deletions src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function AssigneeStep({policy, stepNames, startStepIndex}: AssigneeStepProps) {
const {isOffline} = useNetwork();
const policyID = policy?.id;
const [issueNewCard] = useOnyx(`${ONYXKEYS.COLLECTION.ISSUE_NEW_EXPENSIFY_CARD}${policyID}`, {canBeMissing: true});
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});
const currency = useCurrencyForExpensifyCard({policyID});

const isEditing = issueNewCard?.isEditing;
Expand Down Expand Up @@ -123,7 +124,7 @@ function AssigneeStep({policy, stepNames, startStepIndex}: AssigneeStepProps) {
];
}

const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm).toLowerCase();
const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm, countryCode).toLowerCase();
const filteredOptions = tokenizedSearch(membersDetails, searchValue, (option) => [option.text ?? '', option.alternateText ?? '']);

return [
Expand All @@ -133,7 +134,7 @@ function AssigneeStep({policy, stepNames, startStepIndex}: AssigneeStepProps) {
shouldShow: true,
},
];
}, [membersDetails, debouncedSearchTerm]);
}, [debouncedSearchTerm, countryCode, membersDetails]);

const headerMessage = useMemo(() => {
const searchValue = debouncedSearchTerm.trim().toLowerCase();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Text from '@components/Text';
import useDebouncedState from '@hooks/useDebouncedState';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import usePolicy from '@hooks/usePolicy';
import useThemeStyles from '@hooks/useThemeStyles';
import {clearErrors, inviteWorkspaceEmployeesToUber} from '@libs/actions/Policy/Policy';
Expand All @@ -24,6 +25,7 @@ import tokenizedSearch from '@libs/tokenizedSearch';
import type {WorkspaceSplitNavigatorParamList} from '@navigation/types';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';

type InviteReceiptPartnerPolicyPageProps = PlatformStackScreenProps<WorkspaceSplitNavigatorParamList, typeof SCREENS.WORKSPACE.RECEIPT_PARTNERS_INVITE>;
Expand All @@ -35,6 +37,7 @@ function InviteReceiptPartnerPolicyPage({route}: InviteReceiptPartnerPolicyPageP
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
const [selectedOptions, setSelectedOptions] = useState<MemberForList[]>([]);
const [isInvitationSent, setIsInvitationSent] = useState(false);
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});

const policyID = route.params?.policyID;
const policy = usePolicy(policyID);
Expand Down Expand Up @@ -90,14 +93,14 @@ function InviteReceiptPartnerPolicyPage({route}: InviteReceiptPartnerPolicyPageP

// Apply search filter if there's a search term
if (debouncedSearchTerm) {
const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm).toLowerCase();
const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm, countryCode).toLowerCase();
membersToDisplay = tokenizedSearch(workspaceMembers, searchValue, (option) => [option.text ?? '', option.alternateText ?? '']);
}

// Filter to show selected members first, then apply search filter to selected members
let filterSelectedOptions = selectedOptions;
if (debouncedSearchTerm !== '') {
const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm).toLowerCase();
const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm, countryCode).toLowerCase();
filterSelectedOptions = selectedOptions.filter((option) => {
const isPartOfSearchTerm = !!option.text?.toLowerCase().includes(searchValue) || !!option.login?.toLowerCase().includes(searchValue);
return isPartOfSearchTerm;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {ListItem, Section} from '@components/SelectionList/types';
import UserListItem from '@components/SelectionList/UserListItem';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useOnyx from '@hooks/useOnyx';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
Expand All @@ -24,6 +25,7 @@ import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullsc
import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading';
import {setWorkspacePayer} from '@userActions/Policy/Policy';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import type {PersonalDetailsList, PolicyEmployee} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
Expand All @@ -43,6 +45,7 @@ function WorkspaceWorkflowsPayerPage({route, policy, personalDetails, isLoadingR
const {translate, formatPhoneNumber} = useLocalize();
const policyName = policy?.name ?? '';
const {isOffline} = useNetwork();
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: false});

const [searchTerm, setSearchTerm] = useState('');

Expand Down Expand Up @@ -110,7 +113,7 @@ function WorkspaceWorkflowsPayerPage({route, policy, personalDetails, isLoadingR
const sectionsArray: MembersSection[] = [];

if (searchTerm !== '') {
const searchValue = getSearchValueForPhoneOrEmail(searchTerm);
const searchValue = getSearchValueForPhoneOrEmail(searchTerm, countryCode);
const filteredOptions = tokenizedSearch([...formattedPolicyAdmins, ...formattedAuthorizedPayer], searchValue, (option) => [option.text ?? '', option.login ?? '']);

return [
Expand All @@ -133,7 +136,7 @@ function WorkspaceWorkflowsPayerPage({route, policy, personalDetails, isLoadingR
shouldShow: true,
});
return sectionsArray;
}, [formattedPolicyAdmins, formattedAuthorizedPayer, translate, searchTerm]);
}, [searchTerm, formattedAuthorizedPayer, translate, formattedPolicyAdmins, countryCode]);

const headerMessage = useMemo(
() => (searchTerm && !sections.at(0)?.data.length ? translate('common.noResultsFound') : ''),
Expand Down
Loading
Loading