diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportNavigation.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportNavigation.tsx index c2a0d096c1f66..9a9d656b1c38c 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportNavigation.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportNavigation.tsx @@ -56,7 +56,6 @@ function MoneyRequestReportNavigation({reportID, shouldDisplayNarrowVersion}: Mo archivedReportsIDList: archivedReportsIdSet, isActionLoadingSet, cardFeeds, - shouldSkipActionFiltering: true, }); results = getSortedSections(type, status ?? '', searchData, localeCompare, translate, sortBy, sortOrder, groupBy).map((value) => value.reportID); } diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 767d836fa0769..cd00f8181f601 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -157,7 +157,6 @@ type GetReportSectionsParams = { allTransactionViolations: OnyxCollection; bankAccountList: OnyxEntry; reportActions?: Record; - shouldSkipActionFiltering?: boolean; }; const transactionColumnNamesToSortingProperty: TransactionSorting = { @@ -244,21 +243,10 @@ const expenseStatusActionMapping = { [CONST.SEARCH.STATUS.EXPENSE.ALL]: () => true, }; -const actionFilterMapping = { - [CONST.SEARCH.ACTION_FILTERS.SUBMIT]: expenseStatusActionMapping[CONST.SEARCH.STATUS.EXPENSE.DRAFTS], - [CONST.SEARCH.ACTION_FILTERS.APPROVE]: expenseStatusActionMapping[CONST.SEARCH.STATUS.EXPENSE.OUTSTANDING], - [CONST.SEARCH.ACTION_FILTERS.PAY]: expenseStatusActionMapping[CONST.SEARCH.STATUS.EXPENSE.APPROVED], - [CONST.SEARCH.ACTION_FILTERS.EXPORT]: () => true, -}; - function isValidExpenseStatus(status: unknown): status is ValueOf { return typeof status === 'string' && status in expenseStatusActionMapping; } -function isValidActionFilter(action: unknown): action is ValueOf { - return typeof action === 'string' && action in actionFilterMapping; -} - function getExpenseStatusOptions(translate: LocalizedTranslate): Array> { return [ {text: translate('common.unreported'), value: CONST.SEARCH.STATUS.EXPENSE.UNREPORTED}, @@ -379,7 +367,6 @@ type GetSectionsParams = { isActionLoadingSet?: ReadonlySet; cardFeeds?: OnyxCollection; allTransactionViolations?: OnyxCollection; - shouldSkipActionFiltering?: boolean; }; /** @@ -1730,7 +1717,6 @@ function getReportSections({ allTransactionViolations, bankAccountList, reportActions = {}, - shouldSkipActionFiltering = false, }: GetReportSectionsParams): [TransactionGroupListItemType[], number] { const shouldShowMerchant = getShouldShowMerchant(data); @@ -1795,11 +1781,6 @@ function getReportSections({ shouldShow = isValidExpenseStatus(status) ? expenseStatusActionMapping[status](reportItem) : false; } } - const actionFromQuery = queryJSON?.flatFilters?.find((filter) => filter.key === CONST.SEARCH.SYNTAX_FILTER_KEYS.ACTION)?.filters?.at(0)?.value; - - if (!shouldSkipActionFiltering && actionFromQuery && isValidActionFilter(actionFromQuery)) { - shouldShow = shouldShow && actionFilterMapping[actionFromQuery](reportItem); - } } if (shouldShow) { @@ -2114,7 +2095,6 @@ function getSections({ isActionLoadingSet, cardFeeds, allTransactionViolations, - shouldSkipActionFiltering, }: GetSectionsParams) { if (type === CONST.SEARCH.DATA_TYPES.CHAT) { return getReportActionsSections(data); @@ -2136,7 +2116,6 @@ function getSections({ allTransactionViolations, bankAccountList, reportActions, - shouldSkipActionFiltering, }); } diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index 71c4ad4b97a79..8b8f79a025b89 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -25,7 +25,6 @@ import {setOptimisticDataForTransactionThreadPreview} from '@userActions/Search' import CONST from '@src/CONST'; import IntlStore from '@src/languages/IntlStore'; import type {CardFeedForDisplay} from '@src/libs/CardFeedUtils'; -import * as SearchQueryUtils from '@src/libs/SearchQueryUtils'; import * as SearchUIUtils from '@src/libs/SearchUIUtils'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -49,10 +48,6 @@ jest.mock('@userActions/Search', () => ({ ...jest.requireActual('@userActions/Search'), setOptimisticDataForTransactionThreadPreview: jest.fn(), })); -jest.mock('@src/libs/SearchQueryUtils', () => ({ - ...jest.requireActual('@src/libs/SearchQueryUtils'), - getCurrentSearchQueryJSON: jest.fn(), -})); const adminAccountID = 18439984; const adminEmail = 'admin@policy.com'; @@ -2241,73 +2236,6 @@ describe('SearchUIUtils', () => { }); }); - describe('Test getSections with shouldSkipActionFiltering option', () => { - beforeEach(() => { - // Mock getCurrentSearchQueryJSON to return a query with action filter - (SearchQueryUtils.getCurrentSearchQueryJSON as jest.Mock).mockReturnValue({ - type: 'expense-report', - filters: { - operator: 'and', - left: {operator: 'eq', left: 'action', right: 'approve'}, - }, - flatFilters: [ - { - key: 'action', - filters: [{operator: 'eq', value: 'approve'}], - }, - ], - }); - }); - - afterEach(() => { - (SearchQueryUtils.getCurrentSearchQueryJSON as jest.Mock).mockClear(); - }); - - it('should return all expense reports when shouldSkipActionFiltering is true', () => { - const result = SearchUIUtils.getSections({ - type: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT, - data: searchResults.data, - currentAccountID: 2074551, - currentUserEmail: '', - translate: translateLocal, - formatPhoneNumber, - bankAccountList: {}, - shouldSkipActionFiltering: true, - })[0] as TransactionGroupListItemType[]; - - expect(result.length).toBe(4); // All expense reports returned - }); - - it('should return only filtered expense reports when shouldSkipActionFiltering is false', () => { - const result = SearchUIUtils.getSections({ - type: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT, - data: searchResults.data, - currentAccountID: 2074551, - currentUserEmail: '', - translate: translateLocal, - formatPhoneNumber, - bankAccountList: {}, - shouldSkipActionFiltering: false, - })[0] as TransactionGroupListItemType[]; - - expect(result.length).toBe(2); // Only filtered expense reports returned - }); - - it('should apply default filtering behavior when shouldSkipActionFiltering is undefined', () => { - const result = SearchUIUtils.getSections({ - type: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT, - data: searchResults.data, - currentAccountID: 2074551, - currentUserEmail: '', - translate: translateLocal, - formatPhoneNumber, - bankAccountList: {}, - })[0] as TransactionGroupListItemType[]; - - expect(result.length).toBe(2); // Default behavior applies filtering - }); - }); - describe('Test getSortedSections', () => { it('should return getSortedReportActionData result when type is CHAT', () => { const sortedActions = SearchUIUtils.getSortedSections(