Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2205,8 +2205,14 @@ function getMemberInviteOptions(
/**
* Helper method that returns the text to be used for the header's message and title (if any)
*/
function getHeaderMessage(hasSelectableOptions: boolean, hasUserToInvite: boolean, searchValue: string, hasMatchedParticipant = false): string {
const isValidPhone = parsePhoneNumber(appendCountryCode(searchValue)).possible;
function getHeaderMessage(
hasSelectableOptions: boolean,
hasUserToInvite: boolean,
searchValue: string,
hasMatchedParticipant = false,
countryCode: OnyxEntry<number> = CONST.DEFAULT_COUNTRY_CODE,
): string {
const isValidPhone = parsePhoneNumber(appendCountryCodeWithCountryCode(searchValue, countryCode)).possible;

const isValidEmail = Str.isValidEmail(searchValue);

Expand Down
2 changes: 2 additions & 0 deletions src/pages/InviteReportParticipantsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ function InviteReportParticipantsPage({report, didScreenTransitionEnd}: InviteRe
selectedOptionsForDisplay.length + availableOptions.recentReports.length + availableOptions.personalDetails.length !== 0,
!!availableOptions.userToInvite,
processedLogin,
false,
countryCode,
);
}, [searchTerm, availableOptions, selectedOptionsForDisplay, excludedUsers, translate, reportName, countryCode]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWo
) {
return translate('messages.userIsAlreadyMember', {login: searchValue, name: policy?.name ?? ''});
}
return getHeaderMessage(personalDetails.length !== 0, usersToInvite.length > 0, searchValue);
}, [excludedUsers, translate, debouncedSearchTerm, policy?.name, usersToInvite, personalDetails.length]);
return getHeaderMessage(personalDetails.length !== 0, usersToInvite.length > 0, searchValue, false, countryCode);
}, [excludedUsers, translate, debouncedSearchTerm, policy?.name, usersToInvite, personalDetails.length, countryCode]);

const footerContent = useMemo(
() => (
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Share/ShareTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ function ShareTab({ref}: ShareTabProps) {
const [sections, header] = useMemo(() => {
const newSections = [];
newSections.push({title: textInputValue.trim() === '' ? translate('search.recentChats') : undefined, data: styledRecentReports});
const headerMessage = getHeaderMessage(styledRecentReports.length !== 0, false, textInputValue.trim(), false);
const headerMessage = getHeaderMessage(styledRecentReports.length !== 0, false, textInputValue.trim(), false, countryCode);
return [newSections, headerMessage];
}, [textInputValue, styledRecentReports, translate]);
}, [textInputValue, styledRecentReports, translate, countryCode]);

const onSelectRow = (item: OptionData) => {
let reportID = item?.reportID ?? CONST.DEFAULT_NUMBER_ID;
Expand Down
5 changes: 4 additions & 1 deletion src/pages/iou/request/MoneyRequestAccountantSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType
(chatOptions.personalDetails ?? []).length + (chatOptions.recentReports ?? []).length !== 0,
!!chatOptions?.userToInvite,
debouncedSearchTerm.trim(),
false,
countryCode,
);

return [newSections, headerMessage];
Expand All @@ -177,8 +179,9 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType
chatOptions.userToInvite,
debouncedSearchTerm,
personalDetails,
translate,
reportAttributesDerived,
translate,
countryCode,
]);

const selectAccountant = useCallback(
Expand Down
4 changes: 3 additions & 1 deletion src/pages/iou/request/MoneyRequestAttendeeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde
!!chatOptions?.userToInvite,
cleanSearchTerm,
attendees.some((attendee) => getPersonalDetailSearchTerms(attendee).join(' ').toLowerCase().includes(cleanSearchTerm)),
countryCode,
);

return [newSections, headerMessage];
Expand All @@ -225,8 +226,9 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde
cleanSearchTerm,
attendees,
personalDetails,
translate,
reportAttributesDerived,
translate,
countryCode,
]);

const addAttendeeToSelection = useCallback(
Expand Down
2 changes: 2 additions & 0 deletions src/pages/iou/request/MoneyRequestParticipantsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ function MoneyRequestParticipantsSelector({
!!chatOptions?.userToInvite,
debouncedSearchTerm.trim(),
participants.some((participant) => getPersonalDetailSearchTerms(participant).join(' ').toLowerCase().includes(cleanSearchTerm)),
countryCode,
),
[
chatOptions.personalDetails,
Expand All @@ -270,6 +271,7 @@ function MoneyRequestParticipantsSelector({
cleanSearchTerm,
debouncedSearchTerm,
participants,
countryCode,
],
);
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ function BaseShareLogList({onAttachLogToReport}: BaseShareLogListProps) {
(filteredOptions.recentReports?.length || 0) + (filteredOptions.personalDetails?.length || 0) !== 0,
!!filteredOptions.userToInvite,
debouncedSearchValue.trim(),
false,
countryCode,
);

return {...filteredOptions, headerMessage};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function useOptions() {
countryCode,
);

const headerMessage = getHeaderMessage((recentReports?.length || 0) + (personalDetails?.length || 0) !== 0, !!userToInvite, '');
const headerMessage = getHeaderMessage((recentReports?.length || 0) + (personalDetails?.length || 0) !== 0, !!userToInvite, '', false, countryCode);

return {
userToInvite,
Expand All @@ -76,6 +76,8 @@ function useOptions() {
(filteredOptions.recentReports?.length || 0) + (filteredOptions.personalDetails?.length || 0) !== 0,
!!filteredOptions.userToInvite,
debouncedSearchValue,
false,
countryCode,
);

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function useOptions() {
countryCode,
);

const headerMessage = getHeaderMessage((recentReports?.length || 0) + (personalDetails?.length || 0) !== 0, !!userToInvite, '');
const headerMessage = getHeaderMessage((recentReports?.length || 0) + (personalDetails?.length || 0) !== 0, !!userToInvite, '', false, countryCode);

if (isLoading) {
// eslint-disable-next-line react-compiler/react-compiler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ function AccountDetailsPage() {
const {params} = useRoute<PlatformStackRouteProp<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.MERGE_ACCOUNTS.ACCOUNT_DETAILS>>();
const [email, setEmail] = useState(params?.email ?? '');
const {inputCallbackRef} = useAutoFocusInput();

const validateCodeSent = getValidateCodeForAccountMerge?.validateCodeSent;
const latestError = getLatestErrorMessage(getValidateCodeForAccountMerge);
const errorKey = getValidateCodeErrorKey(latestError);
Expand Down
4 changes: 3 additions & 1 deletion src/pages/tasks/TaskAssigneeSelectorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function useOptions() {
countryCode,
);

const headerMessage = getHeaderMessage((recentReports?.length || 0) + (personalDetails?.length || 0) !== 0 || !!currentUserOption, !!userToInvite, '');
const headerMessage = getHeaderMessage((recentReports?.length || 0) + (personalDetails?.length || 0) !== 0 || !!currentUserOption, !!userToInvite, '', false, countryCode);

if (isLoading) {
// eslint-disable-next-line react-compiler/react-compiler
Expand Down Expand Up @@ -98,6 +98,8 @@ function useOptions() {
(filteredOptions.recentReports?.length || 0) + (filteredOptions.personalDetails?.length || 0) !== 0 || !!filteredOptions.currentUserOption,
!!filteredOptions.userToInvite,
debouncedSearchValue,
false,
countryCode,
);

return {
Expand Down
5 changes: 3 additions & 2 deletions src/pages/tasks/TaskShareDestinationSelectorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function TaskShareDestinationSelectorModal() {
const {translate} = useLocalize();
const {isOffline} = useNetwork();
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false, canBeMissing: true});
const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: true});

const {searchTerm, setSearchTerm, availableOptions, areOptionsInitialized, onListEndReached} = useSearchSelector({
selectionMode: CONST.SEARCH_SELECTOR.SELECTION_MODE_SINGLE,
Expand All @@ -95,8 +96,8 @@ function TaskShareDestinationSelectorModal() {
const textInputHint = useMemo(() => (isOffline ? `${translate('common.youAppearToBeOffline')} ${translate('search.resultsAreLimited')}` : ''), [isOffline, translate]);

const headerMessage = useMemo(() => {
return getHeaderMessage(filteredOptions.recentReports && filteredOptions.recentReports.length !== 0, false, searchTerm);
}, [filteredOptions.recentReports, searchTerm]);
return getHeaderMessage(filteredOptions.recentReports && filteredOptions.recentReports.length !== 0, false, searchTerm, false, countryCode);
}, [filteredOptions.recentReports, searchTerm, countryCode]);

const sections = useMemo(
() =>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/workspace/WorkspaceInvitePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ function WorkspaceInvitePage({route, policy}: WorkspaceInvitePageProps) {
) {
return translate('messages.userIsAlreadyMember', {login: searchValue, name: policyName});
}
return getHeaderMessage(personalDetails.length !== 0, usersToInvite.length > 0, searchValue);
}, [excludedUsers, translate, debouncedSearchTerm, policyName, usersToInvite, personalDetails.length]);
return getHeaderMessage(personalDetails.length !== 0, usersToInvite.length > 0, searchValue, false, countryCode);
}, [excludedUsers, translate, debouncedSearchTerm, policyName, usersToInvite, personalDetails.length, countryCode]);

const footerContent = useMemo(
() => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ function AssigneeStep({policy, feed}: AssigneeStepProps) {
const headerMessage = useMemo(() => {
const searchValue = debouncedSearchTerm.trim().toLowerCase();

return getHeaderMessage(sections[0].data.length !== 0, false, searchValue);
}, [debouncedSearchTerm, sections]);
return getHeaderMessage(sections[0].data.length !== 0, false, searchValue, false, countryCode);
}, [debouncedSearchTerm, sections, countryCode]);

return (
<InteractiveStepWrapper
Expand Down
4 changes: 2 additions & 2 deletions src/pages/workspace/expensifyCard/issueNew/AssigneeStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ function AssigneeStep({policy, stepNames, startStepIndex}: AssigneeStepProps) {
const headerMessage = useMemo(() => {
const searchValue = debouncedSearchTerm.trim().toLowerCase();

return getHeaderMessage(sections[0].data.length !== 0, false, searchValue);
}, [debouncedSearchTerm, sections]);
return getHeaderMessage(sections[0].data.length !== 0, false, searchValue, false, countryCode);
}, [debouncedSearchTerm, sections, countryCode]);

return (
<InteractiveStepWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import TabSelector from '@components/TabSelector/TabSelector';
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 useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -31,6 +32,7 @@ import type {WorkspaceSplitNavigatorParamList} from '@navigation/types';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import type {PendingAction} from '@src/types/onyx/OnyxCommon';

Expand All @@ -44,7 +46,7 @@ function EditInviteReceiptPartnerPolicyPage({route}: EditInviteReceiptPartnerPol
const StyleUtils = useStyleUtils();
const {translate, localeCompare} = useLocalize();
const {isOffline} = useNetwork();

const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE, {canBeMissing: true});
const policyID = route.params.policyID;
const policy = usePolicy(policyID);

Expand Down Expand Up @@ -304,7 +306,7 @@ function EditInviteReceiptPartnerPolicyPage({route}: EditInviteReceiptPartnerPol

// Determine header message for search results
const searchValue = debouncedSearchTerm.trim().toLowerCase();
let currentHeaderMessage = getHeaderMessage(members.length !== 0, false, searchValue);
let currentHeaderMessage = getHeaderMessage(members.length !== 0, false, searchValue, false, countryCode);

if (filteredMembers.length === 0 && searchValue) {
currentHeaderMessage = translate('common.noResultsFound');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ function InviteReceiptPartnerPolicyPage({route}: InviteReceiptPartnerPolicyPageP
const headerMessage = useMemo(() => {
const searchValue = debouncedSearchTerm.trim().toLowerCase();

return getHeaderMessage(sections?.at(0)?.data.length !== 0, false, searchValue);
}, [debouncedSearchTerm, sections]);
return getHeaderMessage(sections?.at(0)?.data.length !== 0, false, searchValue, false, countryCode);
}, [debouncedSearchTerm, sections, countryCode]);

const handleConfirm = useCallback(() => {
if (selectedOptions.length === 0) {
Expand Down
Loading