diff --git a/src/components/Search/SearchAutocompleteList.tsx b/src/components/Search/SearchAutocompleteList.tsx index cef351ad4dbe..225382000b1d 100644 --- a/src/components/Search/SearchAutocompleteList.tsx +++ b/src/components/Search/SearchAutocompleteList.tsx @@ -183,7 +183,7 @@ function SearchAutocompleteList( if (!areOptionsInitialized) { return defaultListOptions; } - return getSearchOptions(options, betas ?? [], true, true, autocompleteQueryValue, CONST.AUTO_COMPLETE_SUGGESTER.MAX_AMOUNT_OF_SUGGESTIONS, true); + return getSearchOptions(options, betas ?? [], true, true, autocompleteQueryValue, CONST.AUTO_COMPLETE_SUGGESTER.MAX_AMOUNT_OF_SUGGESTIONS, true, true, false, true); }, [areOptionsInitialized, betas, options, autocompleteQueryValue]); const [isInitialRender, setIsInitialRender] = useState(true); @@ -361,7 +361,7 @@ function SearchAutocompleteList( case CONST.SEARCH.SYNTAX_FILTER_KEYS.FROM: case CONST.SEARCH.SYNTAX_FILTER_KEYS.PAYER: case CONST.SEARCH.SYNTAX_FILTER_KEYS.EXPORTER: { - const participants = getSearchOptions(options, betas ?? [], true, true, autocompleteValue, 10, false, false, true).personalDetails.filter( + const participants = getSearchOptions(options, betas ?? [], true, true, autocompleteValue, 10, false, false, true, true).personalDetails.filter( (participant) => participant.text && !alreadyAutocompletedKeys.includes(participant.text.toLowerCase()), ); @@ -373,7 +373,7 @@ function SearchAutocompleteList( })); } case CONST.SEARCH.SYNTAX_FILTER_KEYS.IN: { - const filteredReports = getSearchOptions(options, betas ?? [], true, true, autocompleteValue, 10, false, true).recentReports; + const filteredReports = getSearchOptions(options, betas ?? [], true, true, autocompleteValue, 10, false, true, false, true).recentReports; return filteredReports.map((chat) => ({ filterKey: CONST.SEARCH.SEARCH_USER_FRIENDLY_KEYS.IN, diff --git a/src/libs/OptionsListUtils/index.ts b/src/libs/OptionsListUtils/index.ts index 3f921db582e2..9f2e8c662109 100644 --- a/src/libs/OptionsListUtils/index.ts +++ b/src/libs/OptionsListUtils/index.ts @@ -809,8 +809,9 @@ function createOption( } // Type/category flags already set in initialization above, but update brickRoadIndicator - result.allReportErrors = reportAttributesDerived?.[report.reportID]?.reportErrors ?? {}; - result.brickRoadIndicator = !isEmptyObject(result.allReportErrors) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : ''; + const reportAttribute = reportAttributesDerived?.[report.reportID]; + result.allReportErrors = reportAttribute?.reportErrors ?? {}; + result.brickRoadIndicator = !isEmptyObject(result.allReportErrors) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : (reportAttribute?.brickRoadStatus ?? ''); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- below is a boolean expression hasMultipleParticipants = personalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat || reportUtilsIsGroupChat(report); @@ -1604,6 +1605,7 @@ function getValidReports(reports: OptionList['reports'], config: GetValidReports shouldSeparateWorkspaceChat, isPerDiemRequest = false, showRBR = true, + shouldShowGBR = false, } = config; const validReportOptions: SearchOptionData[] = []; @@ -1648,6 +1650,10 @@ function getValidReports(reports: OptionList['reports'], config: GetValidReports brickRoadIndicator: showRBR ? option.brickRoadIndicator : null, }; + if (newReportOption.brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.INFO) { + newReportOption.brickRoadIndicator = shouldShowGBR ? CONST.BRICK_ROAD_INDICATOR_STATUS.INFO : null; + } + if (shouldSeparateWorkspaceChat && newReportOption.isPolicyExpenseChat && !newReportOption.private_isArchived) { newReportOption.text = getPolicyName({report}); newReportOption.alternateText = translateLocal('workspace.common.workspace'); @@ -1750,7 +1756,7 @@ function getValidOptions( loginsToExclude[option.login] = true; }); } - const {includeP2P = true, shouldBoldTitleByDefault = true, includeDomainEmail = false, ...getValidReportsConfig} = config; + const {includeP2P = true, shouldBoldTitleByDefault = true, includeDomainEmail = false, shouldShowGBR = false, ...getValidReportsConfig} = config; let filteredReports = options.reports; @@ -1801,6 +1807,7 @@ function getValidOptions( shouldBoldTitleByDefault, shouldSeparateSelfDMChat, shouldSeparateWorkspaceChat, + shouldShowGBR, }); recentReportOptions = recentReports; @@ -1865,6 +1872,9 @@ function getValidOptions( currentUserRef.current = personalDetail; } personalDetail.isBold = shouldBoldTitleByDefault; + if (personalDetail.brickRoadIndicator === CONST.BRICK_ROAD_INDICATOR_STATUS.INFO) { + personalDetail.brickRoadIndicator = shouldShowGBR ? CONST.BRICK_ROAD_INDICATOR_STATUS.INFO : ''; + } } } @@ -1900,6 +1910,7 @@ function getSearchOptions( includeUserToInvite?: boolean, includeRecentReports = true, includeCurrentUser = false, + shouldShowGBR = false, ): Options { Timing.start(CONST.TIMING.LOAD_SEARCH_OPTIONS); Performance.markStart(CONST.TIMING.LOAD_SEARCH_OPTIONS); @@ -1921,6 +1932,7 @@ function getSearchOptions( includeCurrentUser, searchString: searchQuery, includeUserToInvite, + shouldShowGBR, }); Timing.end(CONST.TIMING.LOAD_SEARCH_OPTIONS); diff --git a/src/libs/OptionsListUtils/types.ts b/src/libs/OptionsListUtils/types.ts index e8beece799e8..765c2dc523c9 100644 --- a/src/libs/OptionsListUtils/types.ts +++ b/src/libs/OptionsListUtils/types.ts @@ -150,6 +150,7 @@ type GetValidReportsConfig = { excludeNonAdminWorkspaces?: boolean; isPerDiemRequest?: boolean; showRBR?: boolean; + shouldShowGBR?: boolean; } & GetValidOptionsSharedConfig; type GetValidReportsReturnTypeCombined = {