From 8e24b0a030d4a640f3151e363fb920d2706ca8f8 Mon Sep 17 00:00:00 2001 From: kubabutkiewicz Date: Thu, 26 Feb 2026 10:08:24 +0100 Subject: [PATCH 1/6] feat: Integrate policy tags into search filters and options handling --- .../Search/SearchFiltersChatsSelector.tsx | 4 +- src/hooks/useSearchSelector.base.ts | 6 ++ src/libs/OptionsListUtils/index.ts | 55 +++++++++++++++++-- src/libs/OptionsListUtils/types.ts | 3 +- src/pages/NewChatPage.tsx | 2 + 5 files changed, 63 insertions(+), 7 deletions(-) diff --git a/src/components/Search/SearchFiltersChatsSelector.tsx b/src/components/Search/SearchFiltersChatsSelector.tsx index b445e63a4b821..665da78cac6e0 100644 --- a/src/components/Search/SearchFiltersChatsSelector.tsx +++ b/src/components/Search/SearchFiltersChatsSelector.tsx @@ -64,6 +64,7 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT); const privateIsArchivedMap = usePrivateIsArchivedMap(); const [nvpDismissedProductTraining] = useOnyx(ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS); const selectedOptions: OptionData[] = selectedReportIDs.map((id) => { const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${id}`]; @@ -72,8 +73,9 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen const report = getSelectedOptionData( createOptionFromReport({...reportData, reportID: id}, personalDetails, currentUserAccountID, chatReport, privateIsArchived, reportAttributesDerived), ); + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; const isReportArchived = !!privateIsArchived; - const alternateText = getAlternateText(report, {}, isReportArchived, currentUserAccountID, {}, reportAttributesDerived); + const alternateText = getAlternateText(report, {}, isReportArchived, currentUserAccountID, {}, reportAttributesDerived, reportPolicyTags); return {...report, alternateText}; }); diff --git a/src/hooks/useSearchSelector.base.ts b/src/hooks/useSearchSelector.base.ts index 2ef787e971aef..478a638a57111 100644 --- a/src/hooks/useSearchSelector.base.ts +++ b/src/hooks/useSearchSelector.base.ts @@ -176,6 +176,7 @@ function useSearchSelectorBase({ const currentUserAccountID = currentUserPersonalDetails.accountID; const currentUserEmail = currentUserPersonalDetails.email ?? ''; const personalDetails = usePersonalDetails(); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS); const onListEndReached = useDebounce( useCallback(() => { @@ -235,6 +236,7 @@ function useSearchSelectorBase({ searchInputValue: trimmedSearchInput, includeUserToInvite, personalDetails, + policyTags, }, countryCode, reportAttributesDerived?.reports, @@ -259,6 +261,7 @@ function useSearchSelectorBase({ excludeLogins, excludeFromSuggestionsOnly, personalDetails, + policyTags, }, countryCode, reportAttributesDerived?.reports, @@ -290,6 +293,7 @@ function useSearchSelectorBase({ maxElements: maxResults, includeUserToInvite, personalDetails, + policyTags, }, countryCode, reportAttributesDerived?.reports, @@ -320,6 +324,7 @@ function useSearchSelectorBase({ includeCurrentUser, shouldAcceptName: true, personalDetails, + policyTags, }, countryCode, reportAttributesDerived?.reports, @@ -352,6 +357,7 @@ function useSearchSelectorBase({ personalDetails, reportAttributesDerived?.reports, trimmedSearchInput, + policyTags, ]); const isOptionSelected = useMemo(() => { diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 186a2c7281440..186782e78ff7f 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -450,6 +450,7 @@ function getAlternateText( currentUserAccountID: number, lastActorDetails: Partial | null = {}, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], + policyTags?: OnyxEntry, ) { const report = getReportOrDraftReport(option.reportID); // TODO: This allReports usage is temporary and will be removed once the full Onyx.connect() refactor is complete (https://github.com/Expensify/App/issues/66378) @@ -461,7 +462,7 @@ function getAlternateText( const formattedLastMessageText = formatReportLastMessageText(Parser.htmlToText(option.lastMessageText ?? '')) || // eslint-disable-next-line @typescript-eslint/no-deprecated - getLastMessageTextForReport({translate: translateLocal, report, lastActorDetails, isReportArchived, chatReport, reportAttributesDerived}); + getLastMessageTextForReport({translate: translateLocal, report, lastActorDetails, isReportArchived, chatReport, reportAttributesDerived, policyTags}); const reportPrefix = getReportSubtitlePrefix(report); const formattedLastMessageTextWithPrefix = reportPrefix + formattedLastMessageText; @@ -901,6 +902,7 @@ function createOption( config?: PreviewConfig, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], privateIsArchived?: string, + policyTags?: OnyxEntry, ): SearchOptionData { const {showChatPreviewLine = false, forcePolicyNamePreview = false, showPersonalDetails = false, selected, isSelected, isDisabled} = config ?? {}; @@ -984,11 +986,20 @@ function createOption( isReportArchived: !!result.private_isArchived, chatReport, reportAttributesDerived, + policyTags, }); result.alternateText = showPersonalDetails && personalDetail?.login ? personalDetail.login - : getAlternateText(result, {showChatPreviewLine, forcePolicyNamePreview}, !!result.private_isArchived, currentUserAccountID, lastActorDetails, reportAttributesDerived); + : getAlternateText( + result, + {showChatPreviewLine, forcePolicyNamePreview}, + !!result.private_isArchived, + currentUserAccountID, + lastActorDetails, + reportAttributesDerived, + policyTags, + ); const computedReportName = getReportName(report, reportAttributesDerived); @@ -1041,11 +1052,13 @@ function getReportOption( personalDetails: OnyxEntry, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], reportDrafts?: OnyxCollection, + policyTags?: OnyxCollection, ): OptionData { const report = getReportOrDraftReport(participant.reportID, undefined, undefined, reportDrafts); // TODO: This allReports usage is temporary and will be removed once the full Onyx.connect() refactor is complete (https://github.com/Expensify/App/issues/66378) const chatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`]; const visibleParticipantAccountIDs = getParticipantsAccountIDsForDisplay(report, true); + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; const option = createOption( visibleParticipantAccountIDs, @@ -1059,6 +1072,7 @@ function getReportOption( }, reportAttributesDerived, privateIsArchived, + reportPolicyTags, ); // Update text & alternateText because createOption returns workspace name only if report is owned by the user @@ -1103,6 +1117,7 @@ function getReportDisplayOption( privateIsArchived: string | undefined, chatReport: OnyxEntry, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], + policyTags?: OnyxEntry, ): OptionData { const visibleParticipantAccountIDs = getParticipantsAccountIDsForDisplay(report, true); @@ -1118,6 +1133,7 @@ function getReportDisplayOption( }, reportAttributesDerived, privateIsArchived, + policyTags, ); // Update text & alternateText because createOption returns workspace name only if report is owned by the user @@ -1153,6 +1169,7 @@ function getPolicyExpenseReportOption( expenseReport: OnyxEntry, chatReport: OnyxEntry, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], + policyTags?: OnyxEntry, ): SearchOptionData { const visibleParticipantAccountIDs = Object.entries(expenseReport?.participants ?? {}) .filter(([, reportParticipant]) => reportParticipant && !isHiddenForCurrentUser(reportParticipant.notificationPreference)) @@ -1169,6 +1186,8 @@ function getPolicyExpenseReportOption( forcePolicyNamePreview: false, }, reportAttributesDerived, + undefined, + policyTags, ); // Update text & alternateText because createOption returns workspace name only if report is owned by the user @@ -1281,6 +1300,7 @@ function processReport( currentUserAccountID: number, chatReport: OnyxEntry, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], + policyTags?: OnyxEntry, ): { reportMapEntry?: [number, Report]; // The entry to add to reportMapForAccountIDs if applicable reportOption: SearchOption | null; // The report option to add to allReportOptions if applicable @@ -1304,7 +1324,7 @@ function processReport( reportMapEntry, reportOption: { item: report, - ...createOption(accountIDs, personalDetails, report, currentUserAccountID, chatReport, undefined, reportAttributesDerived, privateIsArchived), + ...createOption(accountIDs, personalDetails, report, currentUserAccountID, chatReport, undefined, reportAttributesDerived, privateIsArchived, policyTags), }, }; } @@ -1315,6 +1335,7 @@ function createOptionList( privateIsArchivedMap: PrivateIsArchivedMap, reports: OnyxCollection, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], + policyTags?: OnyxCollection, ) { const span = Sentry.startInactiveSpan({name: 'createOptionList'}); @@ -1342,6 +1363,7 @@ function createOptionList( const report = reportMapForAccountIDs[personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID]; const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`]; const chatReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`]; + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; return { item: personalDetail, @@ -1356,6 +1378,7 @@ function createOptionList( }, reportAttributesDerived, privateIsArchived, + reportPolicyTags, ), }; }); @@ -1397,6 +1420,7 @@ function createFilteredOptionList( searchTerm?: string; betas?: OnyxEntry; } = {}, + policyTags?: OnyxCollection, ) { const {maxRecentReports = 500, includeP2P = true, searchTerm = ''} = options; const reportMapForAccountIDs: Record = {}; @@ -1479,6 +1503,7 @@ function createFilteredOptionList( const report = reportMapForAccountIDs[accountID]; const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`]; const chatReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`]; + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; return { item: personalDetail, ...createOption( @@ -1490,6 +1515,7 @@ function createFilteredOptionList( {showPersonalDetails: true}, reportAttributesDerived, privateIsArchived, + reportPolicyTags, ), }; }) @@ -1509,12 +1535,13 @@ function createOptionFromReport( privateIsArchived: string | undefined, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], config?: PreviewConfig, + policyTags?: OnyxEntry, ) { const accountIDs = getParticipantsAccountIDsForDisplay(report); return { item: report, - ...createOption(accountIDs, personalDetails, report, currentUserAccountID, chatReport, config, reportAttributesDerived, privateIsArchived), + ...createOption(accountIDs, personalDetails, report, currentUserAccountID, chatReport, config, reportAttributesDerived, privateIsArchived, policyTags), }; } @@ -2117,6 +2144,7 @@ function prepareReportOptionsForDisplay( currentUserAccountID: number, config: GetValidReportsConfig, reportAttributesDerived?: ReportAttributesDerivedValue['reports'], + policyTags?: OnyxCollection, ): Array> { const { showChatPreviewLine = false, @@ -2142,12 +2170,21 @@ function prepareReportOptionsForDisplay( continue; } const report = option.item; + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; /** * By default, generated options does not have the chat preview line enabled. * If showChatPreviewLine or forcePolicyNamePreview are true, let's generate and overwrite the alternate text. */ - const alternateText = getAlternateText(option, {showChatPreviewLine, forcePolicyNamePreview}, !!option.private_isArchived, currentUserAccountID, {}, reportAttributesDerived); + const alternateText = getAlternateText( + option, + {showChatPreviewLine, forcePolicyNamePreview}, + !!option.private_isArchived, + currentUserAccountID, + {}, + reportAttributesDerived, + reportPolicyTags, + ); const isSelected = isReportSelected(option, selectedOptions); let isOptionUnread = option.isUnread; @@ -2284,6 +2321,7 @@ function getValidOptions( maxRecentReportElements = undefined, shouldAcceptName = false, personalDetails, + policyTags, ...config }: GetOptionsConfig = {}, countryCode: number = CONST.DEFAULT_COUNTRY_CODE, @@ -2390,6 +2428,7 @@ function getValidOptions( personalDetails, }, reportAttributesDerived, + policyTags, ).at(0); } @@ -2410,6 +2449,7 @@ function getValidOptions( personalDetails, }, reportAttributesDerived, + policyTags, ); workspaceChats = prepareReportOptionsForDisplay( @@ -2426,6 +2466,7 @@ function getValidOptions( personalDetails, }, reportAttributesDerived, + policyTags, ); } else if (recentAttendees && recentAttendees?.length > 0) { recentAttendees.filter((attendee) => { @@ -2550,6 +2591,7 @@ type SearchOptionsConfig = { currentUserEmail: string; personalDetails?: OnyxEntry; reportAttributesDerived?: ReportAttributesDerivedValue['reports']; + policyTags?: OnyxCollection; }; /** @@ -2576,6 +2618,7 @@ function getSearchOptions({ currentUserEmail, reportAttributesDerived, personalDetails, + policyTags, }: SearchOptionsConfig): Options { const optionList = getValidOptions( options, @@ -2606,6 +2649,7 @@ function getSearchOptions({ shouldShowGBR, shouldUnreadBeBold, personalDetails, + policyTags, }, countryCode, reportAttributesDerived, @@ -2746,6 +2790,7 @@ function getMemberInviteOptions( personalDetails: personalDetailsCollection, }, countryCode, + undefined, ); } diff --git a/src/libs/OptionsListUtils/types.ts b/src/libs/OptionsListUtils/types.ts index 678bf92d813c2..0a93ca9889a97 100644 --- a/src/libs/OptionsListUtils/types.ts +++ b/src/libs/OptionsListUtils/types.ts @@ -3,7 +3,7 @@ import type {Section as SelectionListSection} from '@components/SelectionList/Se import type {OptionData} from '@libs/ReportUtils'; import type {AvatarSource} from '@libs/UserAvatarUtils'; import type {IOUAction} from '@src/CONST'; -import type {Beta, Login, PersonalDetails, PersonalDetailsList, Report, ReportActions, TransactionViolation} from '@src/types/onyx'; +import type {Beta, Login, PersonalDetails, PersonalDetailsList, PolicyTagLists, Report, ReportActions, TransactionViolation} from '@src/types/onyx'; import type {Icon, PendingAction} from '@src/types/onyx/OnyxCommon'; /** @@ -163,6 +163,7 @@ type GetValidReportsConfig = { shouldUnreadBeBold?: boolean; shouldAlwaysIncludeDM?: boolean; personalDetails?: OnyxEntry; + policyTags?: OnyxCollection; } & GetValidOptionsSharedConfig; type IsValidReportsConfig = Pick< diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index 2c3c96c591885..94d6502201929 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -71,6 +71,7 @@ function useOptions(reportAttributesDerived: ReportAttributesDerivedValue['repor const {contacts} = useContactImport(); const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT); const allPersonalDetails = usePersonalDetails(); + const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS); const { options: listOptions, @@ -110,6 +111,7 @@ function useOptions(reportAttributesDerived: ReportAttributesDerivedValue['repor includeSelfDM: true, shouldAlwaysIncludeDM: true, personalDetails: allPersonalDetails, + policyTags, }, countryCode, reportAttributesDerived, From 296a8530fc05dd72a14aab9c2dc53ea3e5d78a18 Mon Sep 17 00:00:00 2001 From: kubabutkiewicz Date: Thu, 26 Feb 2026 12:24:54 +0100 Subject: [PATCH 2/6] fix typecheck --- src/libs/OptionsListUtils/index.ts | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index c5ca1c9d0a9c0..eac149c9c99e4 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -1394,7 +1394,18 @@ function processReport( reportMapEntry, reportOption: { item: report, - ...createOption(accountIDs, personalDetails, report, currentUserAccountID, chatReport, undefined, reportAttributesDerived, privateIsArchived,policyTags, visibleReportActionsData), + ...createOption( + accountIDs, + personalDetails, + report, + currentUserAccountID, + chatReport, + undefined, + reportAttributesDerived, + privateIsArchived, + policyTags, + visibleReportActionsData, + ), }, }; } @@ -1556,7 +1567,16 @@ function createFilteredOptionList( const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID}`]; const chatReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`]; const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; - const {reportMapEntry, reportOption} = processReport(report, personalDetails, privateIsArchived, currentUserAccountID, chatReport, reportAttributesDerived,reportPolicyTags, visibleReportActionsData); + const {reportMapEntry, reportOption} = processReport( + report, + personalDetails, + privateIsArchived, + currentUserAccountID, + chatReport, + reportAttributesDerived, + reportPolicyTags, + visibleReportActionsData, + ); if (reportMapEntry) { const [accountID, reportValue] = reportMapEntry; @@ -2282,7 +2302,7 @@ function prepareReportOptionsForDisplay( visibleReportActionsData, undefined, reportAttributesDerived, - reportPolicyTags + reportPolicyTags, ); const isSelected = isReportSelected(option, selectedOptions); @@ -2878,7 +2898,7 @@ function getMemberInviteOptions( maxElements: undefined, personalDetails: personalDetailsCollection, countryCode, - ); + }); } /** From 1bfaf9b31617fa869c88e9fd1f398f08fcad6566 Mon Sep 17 00:00:00 2001 From: kubabutkiewicz Date: Fri, 27 Feb 2026 15:45:43 +0100 Subject: [PATCH 3/6] Refactor policyTags to allPolicyTags in SearchFiltersChatsSelector and related hooks for consistency. Update getNonEmptyStringOnyxID usage to ensure valid policyID handling across components. --- .../Search/SearchFiltersChatsSelector.tsx | 3 ++- src/hooks/useSearchSelector.base.ts | 12 ++++++------ src/libs/OptionsListUtils/index.ts | 14 +++++++------- src/libs/OptionsListUtils/types.ts | 2 +- src/pages/NewChatPage.tsx | 4 ++-- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/components/Search/SearchFiltersChatsSelector.tsx b/src/components/Search/SearchFiltersChatsSelector.tsx index 5ba7c4ebe4075..53615a3481be4 100644 --- a/src/components/Search/SearchFiltersChatsSelector.tsx +++ b/src/components/Search/SearchFiltersChatsSelector.tsx @@ -11,6 +11,7 @@ import usePrivateIsArchivedMap from '@hooks/usePrivateIsArchivedMap'; import useReportAttributes from '@hooks/useReportAttributes'; import useScreenWrapperTransitionStatus from '@hooks/useScreenWrapperTransitionStatus'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; +import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; import {createOptionFromReport, filterAndOrderOptions, formatSectionsFromSearchTerm, getAlternateText, getSearchOptions} from '@libs/OptionsListUtils'; import type {Option} from '@libs/OptionsListUtils'; import type {OptionWithKey, SelectionListSections} from '@libs/OptionsListUtils/types'; @@ -73,7 +74,7 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen const report = getSelectedOptionData( createOptionFromReport({...reportData, reportID: id}, personalDetails, currentUserAccountID, chatReport, privateIsArchived, reportAttributesDerived), ); - const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getNonEmptyStringOnyxID(report?.policyID)}`]; const isReportArchived = !!privateIsArchived; const alternateText = getAlternateText(report, {}, isReportArchived, currentUserAccountID, {}, undefined, undefined, reportAttributesDerived, reportPolicyTags); return {...report, alternateText}; diff --git a/src/hooks/useSearchSelector.base.ts b/src/hooks/useSearchSelector.base.ts index 7e8dcdd4d3c6b..9d950647dcdd6 100644 --- a/src/hooks/useSearchSelector.base.ts +++ b/src/hooks/useSearchSelector.base.ts @@ -177,7 +177,7 @@ function useSearchSelectorBase({ const currentUserAccountID = currentUserPersonalDetails.accountID; const currentUserEmail = currentUserPersonalDetails.email ?? ''; const personalDetails = usePersonalDetails(); - const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS); + const [allPolicyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS); const onListEndReached = useDebounce( useCallback(() => { @@ -232,7 +232,7 @@ function useSearchSelectorBase({ personalDetails, countryCode, reportAttributesDerived: reportAttributesDerived?.reports, - policyTags, + allPolicyTags, }); case CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_GENERAL: return getValidOptions(optionsWithContacts, allPolicies, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, { @@ -248,7 +248,7 @@ function useSearchSelectorBase({ personalDetails, countryCode, reportAttributesDerived: reportAttributesDerived?.reports, - policyTags, + allPolicyTags, }); case CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_SHARE_DESTINATION: return getValidOptions(optionsWithContacts, allPolicies, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, { @@ -271,7 +271,7 @@ function useSearchSelectorBase({ personalDetails, countryCode, reportAttributesDerived: reportAttributesDerived?.reports, - policyTags, + allPolicyTags, }); case CONST.SEARCH_SELECTOR.SEARCH_CONTEXT_ATTENDEES: return getValidOptions(optionsWithContacts, allPolicies, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, { @@ -293,7 +293,7 @@ function useSearchSelectorBase({ personalDetails, countryCode, reportAttributesDerived: reportAttributesDerived?.reports, - policyTags, + allPolicyTags, }); default: return getEmptyOptions(); @@ -324,7 +324,7 @@ function useSearchSelectorBase({ personalDetails, reportAttributesDerived?.reports, trimmedSearchInput, - policyTags, + allPolicyTags, ]); const isOptionSelected = useMemo(() => { diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index eac149c9c99e4..acb2ea12fe509 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -2440,7 +2440,7 @@ function getValidOptions( maxRecentReportElements = undefined, shouldAcceptName = false, personalDetails, - policyTags, + allPolicyTags, countryCode = CONST.DEFAULT_COUNTRY_CODE, visibleReportActionsData = {}, reportAttributesDerived, @@ -2549,7 +2549,7 @@ function getValidOptions( }, visibleReportActionsData, reportAttributesDerived, - policyTags, + allPolicyTags, ).at(0); } @@ -2571,7 +2571,7 @@ function getValidOptions( }, visibleReportActionsData, reportAttributesDerived, - policyTags, + allPolicyTags, ); workspaceChats = prepareReportOptionsForDisplay( @@ -2589,7 +2589,7 @@ function getValidOptions( }, visibleReportActionsData, reportAttributesDerived, - policyTags, + allPolicyTags, ); } else if (recentAttendees && recentAttendees?.length > 0) { recentAttendees.filter((attendee) => { @@ -2715,7 +2715,7 @@ type SearchOptionsConfig = { currentUserEmail: string; personalDetails?: OnyxEntry; reportAttributesDerived?: ReportAttributesDerivedValue['reports']; - policyTags?: OnyxCollection; + allPolicyTags?: OnyxCollection; }; /** @@ -2743,7 +2743,7 @@ function getSearchOptions({ currentUserEmail, reportAttributesDerived, personalDetails, - policyTags, + allPolicyTags, }: SearchOptionsConfig): Options { const optionList = getValidOptions(options, policyCollection, draftComments, nvpDismissedProductTraining, loginList, currentUserAccountID, currentUserEmail, { betas, @@ -2769,7 +2769,7 @@ function getSearchOptions({ countryCode, visibleReportActionsData, reportAttributesDerived, - policyTags, + allPolicyTags, }); return optionList; diff --git a/src/libs/OptionsListUtils/types.ts b/src/libs/OptionsListUtils/types.ts index b59c0745916bf..68cd278381921 100644 --- a/src/libs/OptionsListUtils/types.ts +++ b/src/libs/OptionsListUtils/types.ts @@ -174,7 +174,7 @@ type GetValidReportsConfig = { shouldUnreadBeBold?: boolean; shouldAlwaysIncludeDM?: boolean; personalDetails?: OnyxEntry; - policyTags?: OnyxCollection; + allPolicyTags?: OnyxCollection; } & GetValidOptionsSharedConfig; type IsValidReportsConfig = Pick< diff --git a/src/pages/NewChatPage.tsx b/src/pages/NewChatPage.tsx index 5813ff114da12..0e9dca58518e4 100755 --- a/src/pages/NewChatPage.tsx +++ b/src/pages/NewChatPage.tsx @@ -71,7 +71,7 @@ function useOptions(reportAttributesDerived: ReportAttributesDerivedValue['repor const {contacts} = useContactImport(); const [draftComments] = useOnyx(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT); const allPersonalDetails = usePersonalDetails(); - const [policyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS); + const [allPolicyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS); const { options: listOptions, @@ -111,7 +111,7 @@ function useOptions(reportAttributesDerived: ReportAttributesDerivedValue['repor includeSelfDM: true, shouldAlwaysIncludeDM: true, personalDetails: allPersonalDetails, - policyTags, + allPolicyTags, countryCode, reportAttributesDerived, }, From 2835d0d90a4410dd213295e6358e460e0952c56e Mon Sep 17 00:00:00 2001 From: kubabutkiewicz Date: Fri, 27 Feb 2026 15:56:03 +0100 Subject: [PATCH 4/6] Add ESLint directive to createOption function for parameter limit handling --- src/libs/OptionsListUtils/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index acb2ea12fe509..e95c9b58eb704 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -950,6 +950,7 @@ function getLastMessageTextForReport({ /** * Creates a report list option - optimized for SearchOption context */ +// eslint-disable-next-line max-params, @typescript-eslint/max-params -- this should be handled in the seperate issue function createOption( accountIDs: number[], personalDetails: OnyxInputOrEntry, From 3c387171e84c9d739a093bae8e26c4f509c32e01 Mon Sep 17 00:00:00 2001 From: kubabutkiewicz Date: Fri, 27 Feb 2026 16:04:40 +0100 Subject: [PATCH 5/6] lint fixes --- src/libs/OptionsListUtils/index.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index e95c9b58eb704..1ef2ff053e9e7 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -11,6 +11,7 @@ import type {LocaleContextProps, LocalizedTranslate} from '@components/LocaleCon import type {PrivateIsArchivedMap} from '@hooks/usePrivateIsArchivedMap'; import {getEnabledCategoriesCount} from '@libs/CategoryUtils'; import filterArrayByMatch from '@libs/filterArrayByMatch'; +import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID'; import {isReportMessageAttachment} from '@libs/isReportMessageAttachment'; import {formatPhoneNumber as formatPhoneNumberPhoneUtils} from '@libs/LocalePhoneNumber'; // eslint-disable-next-line @typescript-eslint/no-deprecated @@ -1123,7 +1124,7 @@ function getReportOption( // TODO: This allReports usage is temporary and will be removed once the full Onyx.connect() refactor is complete (https://github.com/Expensify/App/issues/66378) const chatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`]; const visibleParticipantAccountIDs = getParticipantsAccountIDsForDisplay(report, true); - const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getNonEmptyStringOnyxID(report?.policyID)}`]; const option = createOption( visibleParticipantAccountIDs, @@ -1429,7 +1430,7 @@ function createOptionList( for (const report of Object.values(reports)) { const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`]; const chatReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`]; - const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getNonEmptyStringOnyxID(report?.policyID)}`]; const {reportMapEntry, reportOption} = processReport( report, personalDetails, @@ -1456,7 +1457,7 @@ function createOptionList( const report = reportMapForAccountIDs[personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID]; const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`]; const chatReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`]; - const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getNonEmptyStringOnyxID(report?.policyID)}`]; return { item: personalDetail, @@ -1567,7 +1568,7 @@ function createFilteredOptionList( for (const report of limitedReports) { const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID}`]; const chatReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`]; - const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getNonEmptyStringOnyxID(report?.policyID)}`]; const {reportMapEntry, reportOption} = processReport( report, personalDetails, @@ -1608,7 +1609,7 @@ function createFilteredOptionList( const report = reportMapForAccountIDs[accountID]; const privateIsArchived = privateIsArchivedMap[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`]; const chatReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${report?.chatReportID}`]; - const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getNonEmptyStringOnyxID(report?.policyID)}`]; return { item: personalDetail, ...createOption( @@ -2288,7 +2289,7 @@ function prepareReportOptionsForDisplay( continue; } const report = option.item; - const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${report?.policyID ?? ''}`]; + const reportPolicyTags = policyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getNonEmptyStringOnyxID(report?.policyID)}`]; /** * By default, generated options does not have the chat preview line enabled. From 68c2cba2741a98e53f1d41a480a924247672e0a0 Mon Sep 17 00:00:00 2001 From: kubabutkiewicz Date: Tue, 3 Mar 2026 09:22:06 +0100 Subject: [PATCH 6/6] fix spell check --- src/libs/OptionsListUtils/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 1ef2ff053e9e7..015ea4beb112b 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -951,7 +951,7 @@ function getLastMessageTextForReport({ /** * Creates a report list option - optimized for SearchOption context */ -// eslint-disable-next-line max-params, @typescript-eslint/max-params -- this should be handled in the seperate issue +// eslint-disable-next-line max-params, @typescript-eslint/max-params -- this should be handled in the separate issue function createOption( accountIDs: number[], personalDetails: OnyxInputOrEntry,