Skip to content
Open
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 @@ -171,6 +171,7 @@ function OptionRowLHNData({
movedToReport,
currentUserAccountID,
reportAttributesDerived,
visibleReportActionsData,
policyTags,
currentUserLogin: login ?? '',
isTrackIntentUser,
Expand Down
24 changes: 20 additions & 4 deletions src/components/Search/FilterComponents/InSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@ const defaultListOptions = {
};

function getSelectedOptionData(option: Option & Pick<OptionData, 'reportID'>): OptionData {
return {...option, isSelected: true, keyForList: option.keyForList ?? option.reportID};
return {
...option,
isSelected: true,
keyForList: option.keyForList ?? option.reportID,
};
}

function InSelector({value = [], selectionListTextInputStyle, selectionListStyle, autoFocus, ready = true, footer, onChange}: InSelectorProps) {
const {translate, dateFnsLocale} = useLocalize();
const shouldFooterBeInsideList = useShouldFooterBeInsideList();
const {convertToDisplayString} = useCurrencyListActions();
const {convertToDisplayString, convertToDisplayStringWithoutCurrency} = useCurrencyListActions();
const personalDetails = usePersonalDetails();
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
const {options, isLoading} = useFilteredOptions({
Expand All @@ -63,10 +67,14 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle

const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
const [countryCode = CONST.DEFAULT_COUNTRY_CODE] = useOnyx(ONYXKEYS.COUNTRY_CODE);
const [loginList] = useOnyx(ONYXKEYS.LOGINS, {selector: expensifyLoginsSelector});
const [loginList] = useOnyx(ONYXKEYS.LOGINS, {
selector: expensifyLoginsSelector,
});
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const sortedReportActionsData = useSortedReportActionsData();
const sortedActions = sortedReportActionsData?.sortedActions;
const transactionThreadIDs = sortedReportActionsData?.transactionThreadIDs;
const lastActions = sortedReportActionsData?.lastActions;

const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const currentUserAccountID = currentUserPersonalDetails.accountID;
Expand All @@ -91,16 +99,20 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
createOptionFromReport({
dateFnsLocale,
convertToDisplayString,
convertToDisplayStringWithoutCurrency,
report: {...reportData, reportID: id},
personalDetails,
privateIsArchived,
rules,
policy: reportPolicy,
sortedActions,
transactionThreadIDs,
lastActions,
currentUserAccountID,
currentUserLogin: currentUserEmail,
conciergeReportID,
reportAttributesDerived,
isTrackIntentUser,
currentUserAccountID,
}),
),
isSelected,
Expand All @@ -114,13 +126,15 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
{
dateFnsLocale,
convertToDisplayString,
convertToDisplayStringWithoutCurrency,
isReportArchived,
personalDetails,
policy,
reportAttributesDerived,
policyTags: reportPolicyTags,
conciergeReportID,
isTrackIntentUser,
translate,
currentUserAccountID,
rules,
},
Expand All @@ -141,6 +155,7 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
: getSearchOptions({
dateFnsLocale,
convertToDisplayString,
convertToDisplayStringWithoutCurrency,
options,
draftComments,
// This list never had the beta, it used to pass no betas at all, so it stays off on purpose
Expand All @@ -153,6 +168,7 @@ function InSelector({value = [], selectionListTextInputStyle, selectionListStyle
personalDetails,
policyCollection: allPolicies,
sortedActions,
currentUserLogin: currentUserEmail,
conciergeReportID,
isTrackIntentUser,
translate,
Expand Down
22 changes: 20 additions & 2 deletions src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function SearchAutocompleteList({
}: SearchAutocompleteListProps) {
const styles = useThemeStyles();
const {translate, localeCompare, formatPhoneNumber, dateFnsLocale} = useLocalize();
const {convertToDisplayString} = useCurrencyListActions();
const {convertToDisplayString, convertToDisplayStringWithoutCurrency} = useCurrencyListActions();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const contentContainerStyle = useBottomSafeSafeAreaPaddingStyle({
addOfflineIndicatorBottomSafeAreaPadding: true,
Expand All @@ -193,11 +193,15 @@ function SearchAutocompleteList({
const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT);
const [recentSearches, recentSearchesMetadata] = useOnyx(ONYXKEYS.RECENT_SEARCHES);
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE);
const [loginList] = useOnyx(ONYXKEYS.LOGINS, {selector: expensifyLoginsSelector});
const [loginList] = useOnyx(ONYXKEYS.LOGINS, {
selector: expensifyLoginsSelector,
});
const [policies = getEmptyObject<NonNullable<OnyxCollection<Policy>>>()] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [visibleReportActionsData] = useOnyx(ONYXKEYS.DERIVED.VISIBLE_REPORT_ACTIONS);
const sortedReportActionsData = useSortedReportActionsData();
const sortedActions = sortedReportActionsData?.sortedActions;
const transactionThreadIDs = sortedReportActionsData?.transactionThreadIDs;
const lastActions = sortedReportActionsData?.lastActions;
const personalDetails = usePersonalDetails();
const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT);
const [personalAndWorkspaceCards] = useOnyx(ONYXKEYS.DERIVED.PERSONAL_AND_WORKSPACE_CARD_LIST);
Expand Down Expand Up @@ -259,6 +263,7 @@ function SearchAutocompleteList({
return getSearchOptions({
dateFnsLocale,
convertToDisplayString,
convertToDisplayStringWithoutCurrency,
options: listOptions,
draftComments,
isDefaultRoomsBetaEnabled,
Expand All @@ -278,7 +283,13 @@ function SearchAutocompleteList({
currentUserEmail,
policyCollection: policies,
personalDetails,
reportAttributesDerived: reportAttributes,
sortedActions,
transactionThreadIDs,
lastActions,
currentUserLogin: currentUserEmail,
localeCompare,
formatPhoneNumber,
conciergeReportID,
isTrackIntentUser,
translate,
Expand All @@ -296,12 +307,18 @@ function SearchAutocompleteList({
currentUserEmail,
policies,
personalDetails,
reportAttributes,
sortedActions,
transactionThreadIDs,
lastActions,
localeCompare,
formatPhoneNumber,
conciergeReportID,
isTrackIntentUser,
translate,
dateFnsLocale,
convertToDisplayString,
convertToDisplayStringWithoutCurrency,
rules,
]);

Expand Down Expand Up @@ -356,6 +373,7 @@ function SearchAutocompleteList({
loginList,
policies,
visibleReportActionsData,
reportAttributesDerived: reportAttributes,
currentUserAccountID,
currentUserEmail,
personalDetails,
Expand Down
15 changes: 13 additions & 2 deletions src/components/Search/SearchRouter/SearchRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function searchForReportsAndUsersInServer(searchInput: string) {

function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDisplayed, ref}: SearchRouterProps) {
const {translate, formatPhoneNumber, dateFnsLocale} = useLocalize();
const {convertToDisplayString} = useCurrencyListActions();
const {convertToDisplayString, convertToDisplayStringWithoutCurrency} = useCurrencyListActions();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {setShouldResetSearchQuery, getSearchKeyForQuery} = useSearchQueryActions();
Expand All @@ -110,6 +110,8 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
const personalDetails = usePersonalDetails();
const sortedReportActionsData = useSortedReportActionsData();
const sortedActions = sortedReportActionsData?.sortedActions;
const transactionThreadIDs = sortedReportActionsData?.transactionThreadIDs;
const lastActions = sortedReportActionsData?.lastActions;
const {shouldUseNarrowLayout} = useResponsiveLayout();
const {windowHeight} = useWindowDimensions();
const listRef = useRef<SelectionListWithSectionsHandle>(null);
Expand Down Expand Up @@ -238,19 +240,23 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
const option = createOptionFromReport({
dateFnsLocale,
convertToDisplayString,
convertToDisplayStringWithoutCurrency,
report: contextualReport,
personalDetails,
privateIsArchived: contextualReportNVP,
rules,
policy: contextualReportPolicy,
sortedActions,
transactionThreadIDs,
lastActions,
currentUserAccountID,
currentUserLogin: currentUserPersonalDetails.login,
conciergeReportID,
reportAttributesDerived: reportAttributes,
config: {
showPersonalDetails: isOneOnOneChat(contextualReport),
},
isTrackIntentUser,
currentUserAccountID,
});
reportForContextualSearch = option;
}
Expand Down Expand Up @@ -316,13 +322,18 @@ function SearchRouter({onRouterClose, shouldHideInputCaret, isSearchRouterDispla
contextualReport,
personalDetails,
sortedActions,
transactionThreadIDs,
lastActions,
currentUserAccountID,
currentUserPersonalDetails.login,
contextualReportNVP,
contextualReportPolicy,
reportAttributes,
isTrackIntentUser,
dateFnsLocale,
currentUserAccountID,
convertToDisplayString,
convertToDisplayStringWithoutCurrency,
rules,
],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ function SearchRouterOptionsWarmer({onDone}: SearchRouterOptionsWarmerProps) {
const [personalDetails] = useAllPersonalDetails();
const reportAttributes = useReportAttributes();
const sortedReportActionsData = useSortedReportActionsData();
const [allPolicyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS);
const [visibleReportActionsData] = useOnyx(ONYXKEYS.DERIVED.VISIBLE_REPORT_ACTIONS);

const churnVersionRef = useRef(0);
useEffect(() => {
churnVersionRef.current += 1;
}, [reports, policies, personalDetails, reportAttributes, sortedReportActionsData]);
}, [reports, policies, personalDetails, reportAttributes, sortedReportActionsData, allPolicyTags, visibleReportActionsData]);

useEffect(() => {
let attempts = 0;
Expand Down
24 changes: 21 additions & 3 deletions src/hooks/useAutocompleteSuggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {getDatePresets, getHasOptions} from '@libs/SearchUIUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {CardFeeds, CardList, PersonalDetailsList, Policy} from '@src/types/onyx';
import type {VisibleReportActionsDerivedValue} from '@src/types/onyx/DerivedValues';
import type {ReportAttributesDerivedValue, VisibleReportActionsDerivedValue} from '@src/types/onyx/DerivedValues';
import type {Icon} from '@src/types/onyx/OnyxCommon';
import type {SearchDataTypes} from '@src/types/onyx/SearchResults';
import getEmptyArray from '@src/types/utils/getEmptyArray';
Expand Down Expand Up @@ -63,6 +63,7 @@ type UseAutocompleteSuggestionsParams = {
loginList: OnyxEntry<Record<string, unknown>>;
policies: NonNullable<OnyxCollection<Policy>>;
visibleReportActionsData?: VisibleReportActionsDerivedValue;
reportAttributesDerived?: ReportAttributesDerivedValue['reports'];
currentUserAccountID: number;
currentUserEmail: string;
personalDetails: OnyxEntry<PersonalDetailsList>;
Expand Down Expand Up @@ -114,15 +115,16 @@ function useAutocompleteSuggestions({
loginList,
policies,
visibleReportActionsData,
reportAttributesDerived,
currentUserAccountID,
currentUserEmail,
personalDetails,
feedKeysWithCards,
translate,
autocompleteSubstitutions,
}: UseAutocompleteSuggestionsParams): AutocompleteItemData[] {
const {localeCompare, dateFnsLocale} = useLocalize();
const {convertToDisplayString} = useCurrencyListActions();
const {localeCompare, dateFnsLocale, formatPhoneNumber} = useLocalize();
const {convertToDisplayString, convertToDisplayStringWithoutCurrency} = 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 All @@ -133,6 +135,8 @@ function useAutocompleteSuggestions({
const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
const sortedReportActionsData = useSortedReportActionsData();
const sortedActions = sortedReportActionsData?.sortedActions;
const transactionThreadIDs = sortedReportActionsData?.transactionThreadIDs;
const lastActions = sortedReportActionsData?.lastActions;
const {currencyList} = useCurrencyListState();
const {exportedToFilterOptions} = useExportedToFilterOptions();
const [isTrackIntentUser] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED, {selector: isTrackIntentUserSelector});
Expand Down Expand Up @@ -253,6 +257,7 @@ function useAutocompleteSuggestions({
const participants = getSearchOptions({
dateFnsLocale,
convertToDisplayString,
convertToDisplayStringWithoutCurrency,
options,
draftComments,
isDefaultRoomsBetaEnabled,
Expand All @@ -271,7 +276,13 @@ function useAutocompleteSuggestions({
currentUserAccountID,
currentUserEmail,
personalDetails,
reportAttributesDerived,
currentUserLogin: currentUserEmail,
sortedActions,
transactionThreadIDs,
lastActions,
localeCompare,
formatPhoneNumber,
conciergeReportID,
excludeFromSuggestionsOnly: memberExclusions,
isTrackIntentUser,
Expand All @@ -296,6 +307,7 @@ function useAutocompleteSuggestions({
const filteredReports = getSearchOptions({
dateFnsLocale,
convertToDisplayString,
convertToDisplayStringWithoutCurrency,
options,
draftComments,
isDefaultRoomsBetaEnabled,
Expand All @@ -314,7 +326,13 @@ function useAutocompleteSuggestions({
currentUserAccountID,
currentUserEmail,
personalDetails,
reportAttributesDerived,
currentUserLogin: currentUserEmail,
sortedActions,
transactionThreadIDs,
lastActions,
localeCompare,
formatPhoneNumber,
conciergeReportID,
isTrackIntentUser,
translate,
Expand Down
18 changes: 15 additions & 3 deletions src/hooks/useFilteredOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ function useFilteredOptions(config: UseFilteredOptionsConfig): UseFilteredOption
// every recompute, so it doubles as the report-actions invalidation signal for the option-list cache.
const sortedReportActionsData = useSortedReportActionsData();
const sortedActions = sortedReportActionsData?.sortedActions;
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
const transactionThreadIDs = sortedReportActionsData?.transactionThreadIDs;
const lastActions = sortedReportActionsData?.lastActions;
const {accountID: currentUserAccountID, login: currentUserLogin} = useCurrentUserPersonalDetails();
const [allPolicyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS);
const [visibleReportActionsData] = useOnyx(ONYXKEYS.DERIVED.VISIBLE_REPORT_ACTIONS);

const privateIsArchivedMap = usePrivateIsArchivedMap();

Expand All @@ -118,6 +122,9 @@ function useFilteredOptions(config: UseFilteredOptionsConfig): UseFilteredOption
allPolicies,
{
currentUserAccountID,
currentUserLogin,
transactionThreadIDs,
lastActions,
dateFnsLocale,
convertToDisplayString,
conciergeReportID,
Expand All @@ -129,8 +136,8 @@ function useFilteredOptions(config: UseFilteredOptionsConfig): UseFilteredOption
pendingDeleteMemberAccountIDsByReportID,
},
rules,
undefined,
undefined,
allPolicyTags,
visibleReportActionsData,
isTrackIntentUser,
sortedActions,
)
Expand All @@ -150,7 +157,12 @@ function useFilteredOptions(config: UseFilteredOptionsConfig): UseFilteredOption
deferContactsUntilSearch,
preferredLocale,
isTrackIntentUser,
currentUserLogin,
allPolicyTags,
visibleReportActionsData,
sortedActions,
transactionThreadIDs,
lastActions,
currentUserAccountID,
pendingDeleteMemberAccountIDsByReportID,
dateFnsLocale,
Expand Down
Loading
Loading