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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function OptionRowLHNData({
const {currentReportID: currentReportIDValue} = useCurrentReportIDState();
const isReportFocused = isOptionFocused && currentReportIDValue === reportID;
const {translate, localeCompare, dateFnsLocale, formatPhoneNumber} = useLocalize();
const {convertToDisplayString} = useCurrencyListActions();
const {convertToDisplayString, convertToDisplayStringWithoutCurrency} = useCurrencyListActions();
const {login, accountID: currentUserAccountID} = useCurrentUserPersonalDetails();

const oneTransactionThreadReportID = oneTransactionThreadReport?.reportID;
Expand Down Expand Up @@ -162,6 +162,7 @@ function OptionRowLHNData({
lastAction,
translate,
convertToDisplayString,
convertToDisplayStringWithoutCurrency,
localeCompare,
isReportArchived,
lastActionReport,
Expand Down
7 changes: 6 additions & 1 deletion src/components/Search/FilterComponents/InSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import InviteMemberListItem from '@components/SelectionList/ListItem/InviteMembe
import SelectionListWithSections from '@components/SelectionList/SelectionListWithSections';
import type {TextInputOptions} from '@components/SelectionList/types';

import {useCurrencyListActions} from '@hooks/useCurrencyList';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDebouncedState from '@hooks/useDebouncedState';
import useFilteredOptions from '@hooks/useFilteredOptions';
Expand Down Expand Up @@ -48,6 +49,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 {convertToDisplayString} = useCurrencyListActions();
const personalDetails = usePersonalDetails();
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
const {options, isLoading} = useFilteredOptions({
Expand Down Expand Up @@ -84,6 +86,7 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
...getSelectedOptionData(
createOptionFromReport({
dateFnsLocale,
convertToDisplayString,
report: {...reportData, reportID: id},
personalDetails,
privateIsArchived,
Expand All @@ -102,7 +105,7 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
const alternateText = getAlternateText(
report,
{},
{dateFnsLocale, isReportArchived, personalDetails, policy, reportAttributesDerived, policyTags: reportPolicyTags, conciergeReportID, isTrackIntentUser},
{dateFnsLocale, convertToDisplayString, isReportArchived, personalDetails, policy, reportAttributesDerived, policyTags: reportPolicyTags, conciergeReportID, isTrackIntentUser},
);
return {...report, alternateText};
};
Expand All @@ -119,6 +122,7 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
? defaultListOptions
: getSearchOptions({
dateFnsLocale,
convertToDisplayString,
options,
draftComments,
betas: undefined,
Expand All @@ -137,6 +141,7 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle

const chatOptions = filterAndOrderOptions(defaultOptions, cleanSearchTerm, countryCode, loginList, currentUserEmail, currentUserAccountID, personalDetails, {
dateFnsLocale,
convertToDisplayString,
selectedOptions,
excludeLogins: CONST.EXPENSIFY_EMAILS_OBJECT,
});
Expand Down
4 changes: 4 additions & 0 deletions src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {Section, SelectionListWithSectionsHandle} from '@components/Selecti

import useAutocompleteSuggestions from '@hooks/useAutocompleteSuggestions';
import useBottomSafeSafeAreaPaddingStyle from '@hooks/useBottomSafeSafeAreaPaddingStyle';
import {useCurrencyListActions} from '@hooks/useCurrencyList';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDebounce from '@hooks/useDebounce';
import useDebouncedAccessibilityAnnouncement from '@hooks/useDebouncedAccessibilityAnnouncement';
Expand Down Expand Up @@ -180,6 +181,7 @@ function SearchAutocompleteList({
}: SearchAutocompleteListProps) {
const styles = useThemeStyles();
const {translate, localeCompare, formatPhoneNumber, dateFnsLocale} = useLocalize();
const {convertToDisplayString} = useCurrencyListActions();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const contentContainerStyle = useBottomSafeSafeAreaPaddingStyle({
addOfflineIndicatorBottomSafeAreaPadding: true,
Expand Down Expand Up @@ -255,6 +257,7 @@ function SearchAutocompleteList({
}
return getSearchOptions({
dateFnsLocale,
convertToDisplayString,
options: listOptions,
draftComments,
betas: betas ?? [],
Expand Down Expand Up @@ -296,6 +299,7 @@ function SearchAutocompleteList({
isTrackIntentUser,
translate,
dateFnsLocale,
convertToDisplayString,
]);

const [isInitialRender, setIsInitialRender] = useState(true);
Expand Down
4 changes: 4 additions & 0 deletions src/components/Search/SearchRouter/SearchRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {isSearchQueryItem} from '@components/Search/SearchList/ListItem/SearchQu
import type {SearchQueryString} from '@components/Search/types';
import type {SelectionListWithSectionsHandle} from '@components/SelectionList/SelectionListWithSections/types';

import {useCurrencyListActions} from '@hooks/useCurrencyList';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDebouncedState from '@hooks/useDebouncedState';
import useFeedKeysWithAssignedCards from '@hooks/useFeedKeysWithAssignedCards';
Expand Down Expand Up @@ -80,6 +81,7 @@ type SearchRouterProps = {

function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDisplayed, ref}: SearchRouterProps) {
const {translate, formatPhoneNumber, dateFnsLocale} = useLocalize();
const {convertToDisplayString} = useCurrencyListActions();
const styles = useThemeStyles();
const {setShouldResetSearchQuery} = useSearchQueryActions();
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
Expand Down Expand Up @@ -218,6 +220,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla

const option = createOptionFromReport({
dateFnsLocale,
convertToDisplayString,
report: contextualReport,
personalDetails,
privateIsArchived: contextualReportNVP,
Expand Down Expand Up @@ -299,6 +302,7 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
reportAttributes,
isTrackIntentUser,
dateFnsLocale,
convertToDisplayString,
],
);

Expand Down
5 changes: 4 additions & 1 deletion src/hooks/useAutocompleteSuggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {isTrackIntentUserSelector} from '@selectors/Onboarding';

import type {FeedKeysWithAssignedCards} from './useFeedKeysWithAssignedCards';

import {useCurrencyListState} from './useCurrencyList';
import {useCurrencyListActions, useCurrencyListState} from './useCurrencyList';
import useExportedToFilterOptions from './useExportedToFilterOptions';
import useLoadSearchCategoryData from './useLoadSearchCategoryData';
import useLocalize from './useLocalize';
Expand Down Expand Up @@ -120,6 +120,7 @@ function useAutocompleteSuggestions({
autocompleteSubstitutions,
}: UseAutocompleteSuggestionsParams): AutocompleteItemData[] {
const {localeCompare, dateFnsLocale} = useLocalize();
const {convertToDisplayString} = useCurrencyListActions();
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 @@ -247,6 +248,7 @@ function useAutocompleteSuggestions({

const participants = getSearchOptions({
dateFnsLocale,
convertToDisplayString,
options,
draftComments,
betas: betas ?? [],
Expand Down Expand Up @@ -288,6 +290,7 @@ function useAutocompleteSuggestions({

const filteredReports = getSearchOptions({
dateFnsLocale,
convertToDisplayString,
options,
draftComments,
betas: betas ?? [],
Expand Down
15 changes: 14 additions & 1 deletion src/hooks/useFilteredOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import {isTrackIntentUserSelector} from '@selectors/Onboarding';
import {useCallback, useMemo, useState} from 'react';

import {useCurrencyListActions} from './useCurrencyList';
import useCurrentUserPersonalDetails from './useCurrentUserPersonalDetails';
import useLocalize from './useLocalize';
import useOnyx from './useOnyx';
Expand Down Expand Up @@ -90,6 +91,7 @@ function useFilteredOptions(config: UseFilteredOptionsConfig): UseFilteredOption

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

// 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 +112,17 @@ function useFilteredOptions(config: UseFilteredOptionsConfig): UseFilteredOption
reportAttributesDerived,
privateIsArchivedMap,
allPolicies,
{currentUserAccountID, dateFnsLocale, conciergeReportID, maxRecentReports: reportsLimit, includeP2P, isSearching, deferContactsUntilSearch, locale: preferredLocale},
{
currentUserAccountID,
dateFnsLocale,
convertToDisplayString,
conciergeReportID,
maxRecentReports: reportsLimit,
includeP2P,
isSearching,
deferContactsUntilSearch,
locale: preferredLocale,
},
undefined,
undefined,
isTrackIntentUser,
Expand All @@ -134,6 +146,7 @@ function useFilteredOptions(config: UseFilteredOptionsConfig): UseFilteredOption
sortedActions,
currentUserAccountID,
dateFnsLocale,
convertToDisplayString,
],
);

Expand Down
9 changes: 6 additions & 3 deletions src/hooks/useMoneyRequestParticipantsPolicyTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type {Participant} from '@src/types/onyx/IOU';
import type {Locale as DateFnsLocale} from 'date-fns';
import type {OnyxEntry} from 'react-native-onyx';

import {useCurrencyListActions} from './useCurrencyList';
import useParticipantsPolicyTags from './useParticipantsPolicyTags';

type UseMoneyRequestParticipantsPolicyTagsParams = {
Expand Down Expand Up @@ -47,18 +48,20 @@ function useMoneyRequestParticipantsPolicyTags({
translate,
dateFnsLocale,
}: UseMoneyRequestParticipantsPolicyTagsParams): UseMoneyRequestParticipantsPolicyTagsResult {
const participants = getMoneyRequestParticipantOptions(
const {convertToDisplayString} = useCurrencyListActions();
const participants = getMoneyRequestParticipantOptions({
currentUserAccountID,
report,
policy,
personalDetails,
conciergeReportID,
isArchived,
privateIsArchived: isArchived,
reportAttributesDerived,
reportDraft,
translate,
convertToDisplayString,
dateFnsLocale,
);
});
const participantsPolicyTags = useParticipantsPolicyTags(participants);

return {participants, participantsPolicyTags};
Expand Down
6 changes: 6 additions & 0 deletions src/hooks/useSearchSelector/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {usePersonalDetails} from '@components/OnyxListItemProvider';

import {useCurrencyListActions} from '@hooks/useCurrencyList';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDebounce from '@hooks/useDebounce';
import useDebouncedState from '@hooks/useDebouncedState';
Expand Down Expand Up @@ -195,6 +196,7 @@ function useSearchSelectorBase({
shouldSeparateNonExistingSelectedOptions = false,
}: UseSearchSelectorConfig): UseSearchSelectorReturn {
const {translate, dateFnsLocale} = useLocalize();
const {convertToDisplayString} = useCurrencyListActions();
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES);
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
Expand Down Expand Up @@ -290,6 +292,7 @@ function useSearchSelectorBase({
options: optionsWithContacts,
draftComments,
dateFnsLocale,
convertToDisplayString,
betas: betas ?? [],
isUsedInChatFinder: true,
includeReadOnly: true,
Expand Down Expand Up @@ -319,6 +322,7 @@ function useSearchSelectorBase({
conciergeReportID,
{
dateFnsLocale,
convertToDisplayString,
betas: betas ?? [],
searchString: computedSearchTerm,
searchInputValue: trimmedSearchInput,
Expand Down Expand Up @@ -354,6 +358,7 @@ function useSearchSelectorBase({
conciergeReportID,
{
dateFnsLocale,
convertToDisplayString,
betas,
selectedOptions,
includeMultipleParticipantReports: true,
Expand Down Expand Up @@ -391,6 +396,7 @@ function useSearchSelectorBase({
conciergeReportID,
{
dateFnsLocale,
convertToDisplayString,
betas: betas ?? [],
includeP2P: true,
includeSelectedOptions: false,
Expand Down
Loading
Loading