Skip to content
Draft
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
8 changes: 5 additions & 3 deletions src/components/Search/FilterComponents/InSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function getSelectedOptionData(option: Option & Pick<OptionData, 'reportID'>): O
}

function InSelector({value = [], selectionListTextInputStyle, selectionListStyle, autoFocus, ready = true, footer, onChange}: InSelectorProps) {
const {translate, dateFnsLocale} = useLocalize();
const {translate, dateFnsLocale, formatPhoneNumber} = useLocalize();
const personalDetails = usePersonalDetails();
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
const {options, isLoading} = useFilteredOptions({
Expand Down Expand Up @@ -93,6 +93,7 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
conciergeReportID,
reportAttributesDerived,
isTrackIntentUser,
formatPhoneNumber,
}),
),
isSelected,
Expand All @@ -103,7 +104,7 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
const alternateText = getAlternateText(
report,
{},
{dateFnsLocale, isReportArchived, personalDetails, policy, reportAttributesDerived, policyTags: reportPolicyTags, conciergeReportID, isTrackIntentUser},
{dateFnsLocale, isReportArchived, personalDetails, policy, reportAttributesDerived, policyTags: reportPolicyTags, conciergeReportID, isTrackIntentUser, formatPhoneNumber},
);
return {...report, alternateText};
};
Expand Down Expand Up @@ -134,9 +135,10 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
conciergeReportID,
isTrackIntentUser,
translate,
formatPhoneNumber,
}).options;

const chatOptions = filterAndOrderOptions(defaultOptions, cleanSearchTerm, countryCode, loginList, currentUserEmail, currentUserAccountID, personalDetails, {
const chatOptions = filterAndOrderOptions(defaultOptions, cleanSearchTerm, countryCode, formatPhoneNumber, loginList, currentUserEmail, currentUserAccountID, personalDetails, {
dateFnsLocale,
selectedOptions,
excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT,
Expand Down
2 changes: 2 additions & 0 deletions src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ function SearchAutocompleteList({
conciergeReportID,
isTrackIntentUser,
translate,
formatPhoneNumber,
}).options;
}, [
listOptions,
Expand All @@ -300,6 +301,7 @@ function SearchAutocompleteList({
isTrackIntentUser,
translate,
dateFnsLocale,
formatPhoneNumber,
]);

const [isInitialRender, setIsInitialRender] = useState(true);
Expand Down
2 changes: 2 additions & 0 deletions src/components/Search/SearchRouter/SearchRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
showPersonalDetails: isOneOnOneChat(contextualReport),
},
isTrackIntentUser,
formatPhoneNumber,
});
reportForContextualSearch = option;
}
Expand Down Expand Up @@ -299,6 +300,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
reportAttributes,
isTrackIntentUser,
dateFnsLocale,
formatPhoneNumber,
],
);

Expand Down
4 changes: 3 additions & 1 deletion src/hooks/useAutocompleteSuggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function useAutocompleteSuggestions({
translate,
autocompleteSubstitutions,
}: UseAutocompleteSuggestionsParams): AutocompleteItemData[] {
const {localeCompare, dateFnsLocale} = useLocalize();
const {localeCompare, dateFnsLocale, formatPhoneNumber} = useLocalize();
const [allPolicyCategories] = useOnyx(ONYXKEYS.COLLECTION.POLICY_CATEGORIES);
const [allRecentCategories] = useOnyx(ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_CATEGORIES);
const [recentCurrencyAutocompleteList] = useOnyx(ONYXKEYS.RECENTLY_USED_CURRENCIES);
Expand Down Expand Up @@ -270,6 +270,7 @@ function useAutocompleteSuggestions({
excludeFromSuggestionsOnly: memberExclusions,
isTrackIntentUser,
translate,
formatPhoneNumber,
}).options.personalDetails.filter((participant) => participant.text && !alreadyAutocompletedKeys.has(participant.text.toLowerCase()));

return participants.map((participant) => ({
Expand Down Expand Up @@ -310,6 +311,7 @@ function useAutocompleteSuggestions({
conciergeReportID,
isTrackIntentUser,
translate,
formatPhoneNumber,
}).options.recentReports.filter((chat) => {
if (!chat.text) {
return false;
Expand Down
15 changes: 13 additions & 2 deletions src/hooks/useFilteredOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function useFilteredOptions(config: UseFilteredOptionsConfig): UseFilteredOption
const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector});

// Option building is locale-dependent, so a consumer that stays mounted through a language switch recomputes.
const {preferredLocale, dateFnsLocale} = useLocalize();
const {preferredLocale, dateFnsLocale, formatPhoneNumber} = useLocalize();

// Sorted report actions from the RAM_ONLY_SORTED_REPORT_ACTIONS derived value; a new reference on
// every recompute, so it doubles as the report-actions invalidation signal for the option-list cache.
Expand All @@ -110,7 +110,17 @@ function useFilteredOptions(config: UseFilteredOptionsConfig): UseFilteredOption
reportAttributesDerived,
privateIsArchivedMap,
allPolicies,
{currentUserAccountID, dateFnsLocale, conciergeReportID, maxRecentReports: reportsLimit, includeP2P, isSearching, deferContactsUntilSearch, locale: preferredLocale},
{
currentUserAccountID,
dateFnsLocale,
conciergeReportID,
maxRecentReports: reportsLimit,
includeP2P,
isSearching,
deferContactsUntilSearch,
locale: preferredLocale,
formatPhoneNumber,
},
undefined,
undefined,
isTrackIntentUser,
Expand All @@ -130,6 +140,7 @@ function useFilteredOptions(config: UseFilteredOptionsConfig): UseFilteredOption
isSearching,
deferContactsUntilSearch,
preferredLocale,
formatPhoneNumber,
isTrackIntentUser,
sortedActions,
currentUserAccountID,
Expand Down
15 changes: 5 additions & 10 deletions src/hooks/useMoneyRequestParticipantsPolicyTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type UseMoneyRequestParticipantsPolicyTagsParams = {
reportAttributesDerived: ReportAttributesDerivedValue['reports'] | undefined;
reportDraft: OnyxEntry<Report> | undefined;
translate: LocaleContextProps['translate'];
formatPhoneNumber: LocaleContextProps['formatPhoneNumber'];
};

type UseMoneyRequestParticipantsPolicyTagsResult = {
Expand All @@ -46,19 +47,13 @@ function useMoneyRequestParticipantsPolicyTags({
reportDraft,
translate,
dateFnsLocale,
formatPhoneNumber,
}: UseMoneyRequestParticipantsPolicyTagsParams): UseMoneyRequestParticipantsPolicyTagsResult {
const participants = getMoneyRequestParticipantOptions(
currentUserAccountID,
report,
policy,
personalDetails,
conciergeReportID,
isArchived,
reportAttributesDerived,
reportDraft,
const participants = getMoneyRequestParticipantOptions(currentUserAccountID, report, policy, personalDetails, conciergeReportID, isArchived, reportAttributesDerived, reportDraft, {
translate,
dateFnsLocale,
);
formatPhoneNumber,
});
const participantsPolicyTags = useParticipantsPolicyTags(participants);

return {participants, participantsPolicyTags};
Expand Down
6 changes: 5 additions & 1 deletion src/hooks/useSearchSelector/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function useSearchSelectorBase({
shouldKeepSelectedInAvailableOptions = false,
shouldSeparateNonExistingSelectedOptions = false,
}: UseSearchSelectorConfig): UseSearchSelectorReturn {
const {translate, dateFnsLocale} = useLocalize();
const {translate, dateFnsLocale, formatPhoneNumber} = useLocalize();
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES);
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
Expand Down Expand Up @@ -308,6 +308,7 @@ function useSearchSelectorBase({
conciergeReportID,
isTrackIntentUser,
translate,
formatPhoneNumber,
});
case CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_GENERAL:
return getValidOptions(
Expand Down Expand Up @@ -343,6 +344,7 @@ function useSearchSelectorBase({
...appliedGetValidOptionsConfig,
},
translate,
formatPhoneNumber,
);
case CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_SHARE_DESTINATION:
return getValidOptions(
Expand Down Expand Up @@ -380,6 +382,7 @@ function useSearchSelectorBase({
...appliedGetValidOptionsConfig,
},
translate,
formatPhoneNumber,
);
case CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_ATTENDEES:
return getValidOptions(
Expand Down Expand Up @@ -415,6 +418,7 @@ function useSearchSelectorBase({
...appliedGetValidOptionsConfig,
},
translate,
formatPhoneNumber,
);
default:
return getEmptyOptions();
Expand Down
17 changes: 15 additions & 2 deletions src/libs/IOUAmountSubmission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,19 @@ function buildSubmitAmountContext(args: SubmitAmountArgs): SubmitAmountContext {
}

function buildReportParticipants(args: SubmitAmountArgs) {
const {report, policy, currentUserPersonalDetails, reportAttributesDerivedValue, allReportDrafts, allReportNVPs, allPersonalDetails, conciergeReportID, translate, dateFnsLocale} = args;
const {
report,
policy,
currentUserPersonalDetails,
reportAttributesDerivedValue,
allReportDrafts,
allReportNVPs,
allPersonalDetails,
conciergeReportID,
translate,
dateFnsLocale,
formatPhoneNumber,
} = args;
const selectedParticipants = getMoneyRequestParticipantsFromReport(report, currentUserPersonalDetails.accountID);
const reportAttributesReports = reportAttributesDerivedValue?.reports;
const reportIDToCheck = isMoneyRequestReport(report) ? report?.chatReportID : report?.reportID;
Expand All @@ -252,10 +264,11 @@ function buildReportParticipants(args: SubmitAmountArgs) {
const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID;
const privateIsArchived = !!allReportNVPs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${participant.reportID}`]?.private_isArchived;
return participantAccountID
? getParticipantsOption(participant, allPersonalDetails, translate)
? getParticipantsOption(participant, allPersonalDetails, translate, formatPhoneNumber)
: getReportOption(participant, privateIsArchived, policy, allPersonalDetails, conciergeReportID, reportAttributesReports, reportDraft, currentUserPersonalDetails.accountID, {
translate,
dateFnsLocale,
formatPhoneNumber,
});
});
}
Expand Down
Loading
Loading