From 09286e08b31b6132628fb4bed4d573d695a1c996 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Wed, 7 Jan 2026 17:49:22 +0700 Subject: [PATCH 1/4] Enhance Search component and utility functions to include allTransactionViolations parameter for improved report section handling --- src/components/Search/index.tsx | 2 ++ src/libs/SearchUIUtils.ts | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 61a49e95f82c5..24fb4c1803ccd 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -432,6 +432,7 @@ function Search({ queryJSON, isActionLoadingSet, cardFeeds, + allTransactionViolations: violations, }); return [filteredData1, filteredData1.length, allLength]; }, [ @@ -449,6 +450,7 @@ function Search({ email, isActionLoadingSet, cardFeeds, + violations, ]); useEffect(() => { diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 585439a6663be..4f9e84517537b 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -361,6 +361,7 @@ type GetSectionsParams = { queryJSON?: SearchQueryJSON; isActionLoadingSet?: ReadonlySet; cardFeeds?: OnyxCollection; + allTransactionViolations?: OnyxCollection; }; /** @@ -1673,6 +1674,7 @@ function getReportSections( translate: LocalizedTranslate, formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], isActionLoadingSet: ReadonlySet | undefined, + allTransactionViolations: OnyxCollection, reportActions: Record = {}, ): [TransactionGroupListItemType[], number] { const shouldShowMerchant = getShouldShowMerchant(data); @@ -1766,7 +1768,7 @@ function getReportSections( const hasAnyViolationsForReport = hasAnyViolations( reportItem.reportID, - allViolations, + allTransactionViolations ?? allViolations, currentAccountID ?? CONST.DEFAULT_NUMBER_ID, currentUserEmail, allReportTransactions, @@ -2046,6 +2048,7 @@ function getSections({ queryJSON, isActionLoadingSet, cardFeeds, + allTransactionViolations, }: GetSectionsParams) { if (type === CONST.SEARCH.DATA_TYPES.CHAT) { return getReportActionsSections(data); @@ -2055,7 +2058,7 @@ function getSections({ } if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) { - return getReportSections(data, currentSearch, currentAccountID, currentUserEmail, translate, formatPhoneNumber, isActionLoadingSet, reportActions); + return getReportSections(data, currentSearch, currentAccountID, currentUserEmail, translate, formatPhoneNumber, isActionLoadingSet, allTransactionViolations, reportActions); } if (groupBy) { From 6583789cb5b429e7c941aa96b35223a05832e268 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Fri, 9 Jan 2026 10:40:11 +0700 Subject: [PATCH 2/4] Refactor getReportSections to use allTransactionViolations for visibility checks --- src/libs/SearchUIUtils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index c115ba0cd46b1..4559e3975e4c2 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -1809,7 +1809,14 @@ function getReportSections( ); const hasVisibleViolationsForReport = hasAnyViolationsForReport && - ViolationsUtils.hasVisibleViolationsForUser(reportItem, allViolations, currentUserEmail, currentAccountID ?? CONST.DEFAULT_NUMBER_ID, policy, allReportTransactions); + ViolationsUtils.hasVisibleViolationsForUser( + reportItem, + allTransactionViolations ?? allViolations, + currentUserEmail, + currentAccountID ?? CONST.DEFAULT_NUMBER_ID, + policy, + allReportTransactions, + ); reportIDToTransactions[reportKey] = { ...reportItem, From 5ec00e48e8198a97f779f76c290ce03a87a1dba6 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Mon, 12 Jan 2026 22:56:42 +0700 Subject: [PATCH 3/4] Enhance Search Component: Add 'violations' prop and refactor getReportSections for improved readability --- src/components/Search/index.tsx | 1 + src/libs/SearchUIUtils.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 2b8438c644442..9584226815668 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -451,6 +451,7 @@ function Search({ isActionLoadingSet, cardFeeds, bankAccountList, + violations, ]); useEffect(() => { diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 1c6f125c5bab7..1bae386c4e9ee 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -2102,7 +2102,18 @@ function getSections({ } if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) { - return getReportSections(data, currentSearch, currentAccountID, currentUserEmail, translate, formatPhoneNumber, isActionLoadingSet, allTransactionViolations, bankAccountList, reportActions); + return getReportSections( + data, + currentSearch, + currentAccountID, + currentUserEmail, + translate, + formatPhoneNumber, + isActionLoadingSet, + allTransactionViolations, + bankAccountList, + reportActions, + ); } if (groupBy) { From 351a213c236b53832ffc8bc99e0c4258c4a41f47 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Tue, 13 Jan 2026 00:16:43 +0700 Subject: [PATCH 4/4] Enhance getReportSections function by introducing GetReportSectionsParams type for improved parameter handling and readability. --- src/libs/SearchUIUtils.ts | 42 ++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 4f9183d73430f..21eacc585270e 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -145,6 +145,20 @@ type TransactionMemberGroupSorting = ColumnSortMapping; type TransactionWithdrawalIDGroupSorting = ColumnSortMapping; +type GetReportSectionsParams = { + data: OnyxTypes.SearchResults['data']; + currentSearch: SearchKey; + currentAccountID: number | undefined; + currentUserEmail: string; + translate: LocalizedTranslate; + formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; + isActionLoadingSet: ReadonlySet | undefined; + allTransactionViolations: OnyxCollection; + bankAccountList: OnyxEntry; + reportActions?: Record; + shouldSkipActionFiltering?: boolean; +}; + const transactionColumnNamesToSortingProperty: TransactionSorting = { [CONST.SEARCH.TABLE_COLUMNS.TO]: 'formattedTo' as const, [CONST.SEARCH.TABLE_COLUMNS.FROM]: 'formattedFrom' as const, @@ -1702,19 +1716,19 @@ function getReportActionsSections(data: OnyxTypes.SearchResults['data']): [Repor * * Do not use directly, use only via `getSections()` facade. */ -function getReportSections( - data: OnyxTypes.SearchResults['data'], - currentSearch: SearchKey, - currentAccountID: number | undefined, - currentUserEmail: string, - translate: LocalizedTranslate, - formatPhoneNumber: LocaleContextProps['formatPhoneNumber'], - isActionLoadingSet: ReadonlySet | undefined, - allTransactionViolations: OnyxCollection, - bankAccountList: OnyxEntry, - reportActions: Record = {}, +function getReportSections({ + data, + currentSearch, + currentAccountID, + currentUserEmail, + translate, + formatPhoneNumber, + isActionLoadingSet, + allTransactionViolations, + bankAccountList, + reportActions = {}, shouldSkipActionFiltering = false, -): [TransactionGroupListItemType[], number] { +}: GetReportSectionsParams): [TransactionGroupListItemType[], number] { const shouldShowMerchant = getShouldShowMerchant(data); const { @@ -2105,7 +2119,7 @@ function getSections({ } if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) { - return getReportSections( + return getReportSections({ data, currentSearch, currentAccountID, @@ -2117,7 +2131,7 @@ function getSections({ bankAccountList, reportActions, shouldSkipActionFiltering, - ); + }); } if (groupBy) {