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 @@ -171,6 +171,7 @@ function OptionRowLHNData({
movedToReport,
currentUserAccountID,
reportAttributesDerived,
visibleReportActionsData,
policyTags,
currentUserLogin: login ?? '',
isTrackIntentUser,
Expand Down
8 changes: 1 addition & 7 deletions src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {usePersonalDetails, useCardList, useWorkspaceCardList} from '@components/OnyxListItemProvider';
import {usePersonalDetails} from '@components/OnyxListItemProvider';
import OptionsListSkeletonView from '@components/OptionsListSkeletonView';
import type {AnimatedTextInputRef} from '@components/RNTextInput';
import BareUserListItem from '@components/SelectionList/ListItem/BareUserListItem';
Expand Down Expand Up @@ -190,8 +190,6 @@ function SearchAutocompleteList({
const isDefaultRoomsBetaEnabled = isBetaEnabled(CONST.BETAS.DEFAULT_ROOMS);
const feedKeysWithCards = useFeedKeysWithAssignedCards();
const reportAttributes = useReportAttributes();
const cardList = useCardList();
const workspaceCardList = useWorkspaceCardList();
const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT);
const [recentSearches, recentSearchesMetadata] = useOnyx(ONYXKEYS.RECENT_SEARCHES);
const [countryCode] = useOnyx(ONYXKEYS.COUNTRY_CODE);
Expand Down Expand Up @@ -290,8 +288,6 @@ function SearchAutocompleteList({
transactionThreadIDs,
lastActions,
currentUserLogin: currentUserEmail,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
conciergeReportID,
Expand All @@ -315,8 +311,6 @@ function SearchAutocompleteList({
sortedActions,
transactionThreadIDs,
lastActions,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
conciergeReportID,
Expand Down
7 changes: 0 additions & 7 deletions src/hooks/useAutocompleteSuggestions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type {LocaleContextProps} from '@components/LocaleContextProvider';
import {useCardList, useWorkspaceCardList} from '@components/OnyxListItemProvider';
import type {SubstitutionMap} from '@components/Search/SearchRouter/getQueryWithSubstitutions';
import {getSubstitutionMapKey, getSubstitutionMapKeyWithIndex} from '@components/Search/SearchRouter/getQueryWithSubstitutions';
import type {SearchFilterKey, UserFriendlyKey} from '@components/Search/types';
Expand Down Expand Up @@ -134,8 +133,6 @@ function useAutocompleteSuggestions({
const [allPoliciesTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS);
const [allRecentTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_RECENTLY_USED_TAGS);
const [bankAccountList] = useOnyx(ONYXKEYS.BANK_ACCOUNT_LIST);
const cardList = useCardList();
const workspaceCardList = useWorkspaceCardList();
const sortedReportActionsData = useSortedReportActionsData();
const sortedActions = sortedReportActionsData?.sortedActions;
const transactionThreadIDs = sortedReportActionsData?.transactionThreadIDs;
Expand Down Expand Up @@ -284,8 +281,6 @@ function useAutocompleteSuggestions({
sortedActions,
transactionThreadIDs,
lastActions,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
conciergeReportID,
Expand Down Expand Up @@ -336,8 +331,6 @@ function useAutocompleteSuggestions({
sortedActions,
transactionThreadIDs,
lastActions,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
conciergeReportID,
Expand Down
12 changes: 1 addition & 11 deletions src/hooks/useSearchSelector/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {usePersonalDetails, useCardList, useWorkspaceCardList} from '@components/OnyxListItemProvider';
import {usePersonalDetails} from '@components/OnyxListItemProvider';

import {useCurrencyListActions} from '@hooks/useCurrencyList';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
Expand Down Expand Up @@ -206,8 +206,6 @@ function useSearchSelectorBase({
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const currentUserAccountID = currentUserPersonalDetails.accountID;
const currentUserEmail = currentUserPersonalDetails.email ?? '';
const cardList = useCardList();
const workspaceCardList = useWorkspaceCardList();
const personalDetails = usePersonalDetails();
const [allPolicyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS);
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
Expand Down Expand Up @@ -313,8 +311,6 @@ function useSearchSelectorBase({
transactionThreadIDs,
lastActions,
currentUserLogin: currentUserEmail,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
conciergeReportID,
Expand Down Expand Up @@ -356,8 +352,6 @@ function useSearchSelectorBase({
sortedActions,
transactionThreadIDs,
lastActions,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
isTrackIntentUser,
Expand Down Expand Up @@ -403,8 +397,6 @@ function useSearchSelectorBase({
sortedActions,
transactionThreadIDs,
lastActions,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
isTrackIntentUser,
Expand Down Expand Up @@ -447,8 +439,6 @@ function useSearchSelectorBase({
sortedActions,
transactionThreadIDs,
lastActions,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
isTrackIntentUser,
Expand Down
49 changes: 9 additions & 40 deletions src/libs/OptionsListUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import {
getSubmitToAccountID,
isTimeTrackingEnabled,
} from '@libs/PolicyUtils';
import {getIOUReportIDFromReportActionPreview, getOneTransactionThreadReportID, isActionOfType, isCardIssuedAction} from '@libs/ReportActionsUtils';
import {getIOUReportIDFromReportActionPreview, getOneTransactionThreadReportID, isActionOfType} from '@libs/ReportActionsUtils';
import type {LastActionContext} from '@libs/ReportAlternateTextUtils';
import {getExpensifyCardFromReportAction, getLastMessageTextForReport, getReportAlternateText, resolveLastActionContext} from '@libs/ReportAlternateTextUtils';
import {getLastMessageTextForReport, getReportAlternateText, resolveLastActionContext} from '@libs/ReportAlternateTextUtils';
import {getReportName} from '@libs/ReportNameUtils';
import type {OptionData} from '@libs/ReportUtils';
import {
Expand Down Expand Up @@ -76,7 +76,6 @@ import CONST from '@src/CONST';
import IntlStore from '@src/languages/IntlStore';
import ONYXKEYS from '@src/ONYXKEYS';
import type {
CardList,
Locale,
Login,
OnyxInputOrEntry,
Expand All @@ -92,7 +91,6 @@ import type {
ReportAttributesDerivedValue,
Rule,
VisibleReportActionsDerivedValue,
WorkspaceCardsList,
} from '@src/types/onyx';
import type {Participant} from '@src/types/onyx/IOU';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
Expand Down Expand Up @@ -253,8 +251,6 @@ type GetAlternateTextConfig = {
// TODO: Remove optional (?) once all callers pass currentUserAccountID. Refactor issue: https://github.com/Expensify/App/issues/66408
currentUserAccountID?: number;
currentUserLogin?: string;
cardList?: OnyxEntry<CardList>;
workspaceCardList?: OnyxCollection<WorkspaceCardsList>;
localeCompare?: LocaleContextProps['localeCompare'];
formatPhoneNumber?: LocaleContextProps['formatPhoneNumber'];
/** Resolved by the caller when it already did the lookup, so the last-action scan is not repeated here. */
Expand Down Expand Up @@ -302,8 +298,6 @@ function getAlternateText(
isTrackIntentUser,
currentUserAccountID,
currentUserLogin,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
lastActionContext,
Expand All @@ -324,22 +318,12 @@ function getAlternateText(
const oneTransactionThreadReportID = transactionThreadIDs?.[report.reportID];
const {lastAction, lastActionReport, movedFromReport, movedToReport} =
lastActionContext ?? resolveLastActionContext(report, isReportArchived, visibleReportActionsData, oneTransactionThreadReportID);
const card = isCardIssuedAction(lastAction)
? getExpensifyCardFromReportAction({
reportAction: lastAction,
policy,
cardList,
workspaceCardList,
})
: undefined;
return getReportAlternateText({
report,
lastAction,
lastActionReport,
movedFromReport,
movedToReport,
card,
lastMessageTextFromReport: option.lastMessageText,
personalDetails,
policy,
invoiceReceiverPolicy,
Expand Down Expand Up @@ -2100,6 +2084,12 @@ registerSessionCleanupCallback(() => {
alternateTextCacheInputs = undefined;
});

/** Clears the preview cache. For tests that measure or exercise the resolve path while the guarded inputs keep their identity. */
function clearAlternateTextCache() {
alternateTextCache.clear();
alternateTextCacheInputs = undefined;
}

/** Drops every cached preview as soon as any input that feeds `getAlternateText` changes identity. */
function syncAlternateTextCache(inputs: unknown[]) {
if (alternateTextCacheInputs?.length === inputs.length && inputs.every((input, index) => input === alternateTextCacheInputs?.at(index))) {
Expand Down Expand Up @@ -2156,8 +2146,6 @@ function prepareReportOptionsForDisplay(
dateFnsLocale: DateFnsLocale | undefined;
currentUserAccountID?: number;
currentUserLogin?: string;
cardList?: OnyxEntry<CardList>;
workspaceCardList?: OnyxCollection<WorkspaceCardsList>;
localeCompare?: LocaleContextProps['localeCompare'];
formatPhoneNumber?: LocaleContextProps['formatPhoneNumber'];
transactionThreadIDs?: Record<string, string | undefined>;
Expand Down Expand Up @@ -2189,8 +2177,6 @@ function prepareReportOptionsForDisplay(
convertToDisplayStringWithoutCurrency,
currentUserAccountID,
currentUserLogin,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
transactionThreadIDs,
Expand All @@ -2212,8 +2198,6 @@ function prepareReportOptionsForDisplay(
transactionThreadIDs,
lastActions,
rules,
cardList,
workspaceCardList,
conciergeReportID,
isTrackIntentUser,
currentUserAccountID,
Expand Down Expand Up @@ -2270,8 +2254,6 @@ function prepareReportOptionsForDisplay(
isTrackIntentUser,
currentUserAccountID,
currentUserLogin,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
rules,
Expand Down Expand Up @@ -2385,8 +2367,6 @@ function getValidOptions(
transactionThreadIDs,
lastActions,
currentUserLogin,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
isTrackIntentUser,
Expand Down Expand Up @@ -2538,8 +2518,6 @@ function getValidOptions(
translate,
currentUserAccountID,
currentUserLogin: currentUserLogin ?? currentUserEmail,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
transactionThreadIDs,
Expand Down Expand Up @@ -2574,8 +2552,6 @@ function getValidOptions(
translate,
currentUserAccountID,
currentUserLogin: currentUserLogin ?? currentUserEmail,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
transactionThreadIDs,
Expand Down Expand Up @@ -2606,8 +2582,6 @@ function getValidOptions(
translate,
currentUserAccountID,
currentUserLogin: currentUserLogin ?? currentUserEmail,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
transactionThreadIDs,
Expand Down Expand Up @@ -2787,8 +2761,6 @@ type SearchOptionsConfig = {
transactionThreadIDs?: Record<string, string | undefined>;
lastActions?: Record<string, ReportAction>;
currentUserLogin?: string;
cardList?: OnyxEntry<CardList>;
workspaceCardList?: OnyxCollection<WorkspaceCardsList>;
localeCompare?: LocaleContextProps['localeCompare'];
formatPhoneNumber?: LocaleContextProps['formatPhoneNumber'];
conciergeReportID: string | undefined;
Expand Down Expand Up @@ -2828,8 +2800,6 @@ function getSearchOptions({
transactionThreadIDs,
lastActions,
currentUserLogin,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
conciergeReportID,
Expand Down Expand Up @@ -2880,8 +2850,6 @@ function getSearchOptions({
transactionThreadIDs,
lastActions,
currentUserLogin: currentUserLogin ?? currentUserEmail,
cardList,
workspaceCardList,
localeCompare,
formatPhoneNumber,
excludeFromSuggestionsOnly,
Expand Down Expand Up @@ -3419,6 +3387,7 @@ function processSearchString(searchString: string | undefined): string[] {

export {
canCreateOptimisticPersonalDetailOption,
clearAlternateTextCache,
clearFilteredOptionListCache,
combineOrderingOfReportsAndPersonalDetails,
createOptionFromReport,
Expand Down
4 changes: 0 additions & 4 deletions src/libs/OptionsListUtils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {AvatarSource} from '@libs/UserAvatarUtils';

import type {IOUAction} from '@src/CONST';
import type {
CardList,
Login,
PersonalDetails,
PersonalDetailsList,
Expand All @@ -21,7 +20,6 @@ import type {
ReportAttributesDerivedValue,
TransactionViolation,
VisibleReportActionsDerivedValue,
WorkspaceCardsList,
} from '@src/types/onyx';
import type {Icon, PendingAction} from '@src/types/onyx/OnyxCommon';

Expand Down Expand Up @@ -291,8 +289,6 @@ type GetOptionsConfig = {
transactionThreadIDs?: Record<string, string | undefined>;
lastActions?: Record<string, ReportAction>;
currentUserLogin?: string;
cardList?: OnyxEntry<CardList>;
workspaceCardList?: OnyxCollection<WorkspaceCardsList>;
localeCompare?: LocaleContextProps['localeCompare'];
formatPhoneNumber?: LocaleContextProps['formatPhoneNumber'];
isTrackIntentUser?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ReportAlternateTextUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ type GetReportAlternateTextParams = {
lastActionReport: OnyxEntry<Report>;
movedFromReport?: OnyxEntry<Report>;
movedToReport?: OnyxEntry<Report>;
card: Card | undefined;
card?: Card | undefined;
lastMessageTextFromReport?: string;
personalDetails: OnyxEntry<PersonalDetailsList>;
policy: OnyxEntry<Policy>;
Expand Down
1 change: 1 addition & 0 deletions src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ function getOptionData({
conciergeReportID,
reportAttributesDerived,
visibleReportActionsData,
oneTransactionThreadReportID: reportAttributes?.oneTransactionThreadReportID,
currentUserAccountID,
currentUserLogin,
isTrackIntentUser,
Expand Down
Loading
Loading