From 304d46a56d7579d9fef01f49071599d3ad189dcc Mon Sep 17 00:00:00 2001
From: Carlos Martins <cmartins@expensify.com>
Date: Thu, 8 Aug 2024 20:16:16 +0300
Subject: [PATCH 1/3] add expense status

---
 src/CONST.ts                                  | 10 ++++----
 src/components/Search/SearchPageHeader.tsx    |  4 ++--
 src/components/Search/index.tsx               |  4 ++--
 src/components/Search/types.ts                |  6 ++---
 .../ExportSearchItemsToCSVParams.ts           |  4 ++--
 src/libs/SearchUtils.ts                       | 12 ++++++++++
 src/pages/Search/SearchFiltersStatusPage.tsx  | 24 +++++++++----------
 src/pages/Search/SearchStatusMenu.tsx         | 12 +++++-----
 8 files changed, 45 insertions(+), 31 deletions(-)

diff --git a/src/CONST.ts b/src/CONST.ts
index eaae7b82ef74..395797957238 100755
--- a/src/CONST.ts
+++ b/src/CONST.ts
@@ -5263,10 +5263,12 @@ const CONST = {
             DESC: 'desc',
         },
         STATUS: {
-            ALL: 'all',
-            SHARED: 'shared',
-            DRAFTS: 'drafts',
-            FINISHED: 'finished',
+            EXPENSE: {
+                ALL: 'all',
+                SHARED: 'shared',
+                DRAFTS: 'drafts',
+                FINISHED: 'finished',
+            },
         },
         TYPE: {
             EXPENSE: 'expense',
diff --git a/src/components/Search/SearchPageHeader.tsx b/src/components/Search/SearchPageHeader.tsx
index 039526923b3a..b0f05e6d648a 100644
--- a/src/components/Search/SearchPageHeader.tsx
+++ b/src/components/Search/SearchPageHeader.tsx
@@ -31,7 +31,7 @@ import type {SearchReport} from '@src/types/onyx/SearchResults';
 import type DeepValueOf from '@src/types/utils/DeepValueOf';
 import type IconAsset from '@src/types/utils/IconAsset';
 import {useSearchContext} from './SearchContext';
-import type {SearchQueryJSON, SearchStatus} from './types';
+import type {ExpenseSearchStatus, SearchQueryJSON} from './types';
 
 type HeaderWrapperProps = Pick<HeaderWithBackButtonProps, 'title' | 'subtitle' | 'icon' | 'children'> & {
     subtitleStyles?: StyleProp<TextStyle>;
@@ -100,7 +100,7 @@ type SearchPageHeaderProps = {
 
 type SearchHeaderOptionValue = DeepValueOf<typeof CONST.SEARCH.BULK_ACTION_TYPES> | undefined;
 
-const headerContent: {[key in SearchStatus]: {icon: IconAsset; titleTx: TranslationPaths}} = {
+const headerContent: {[key in ExpenseSearchStatus]: {icon: IconAsset; titleTx: TranslationPaths}} = {
     all: {icon: Illustrations.MoneyReceipts, titleTx: 'common.expenses'},
     shared: {icon: Illustrations.SendMoney, titleTx: 'common.shared'},
     drafts: {icon: Illustrations.Pencil, titleTx: 'common.drafts'},
diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx
index 7283a36e9f59..2109fa969622 100644
--- a/src/components/Search/index.tsx
+++ b/src/components/Search/index.tsx
@@ -31,7 +31,7 @@ import ROUTES from '@src/ROUTES';
 import type SearchResults from '@src/types/onyx/SearchResults';
 import {useSearchContext} from './SearchContext';
 import SearchPageHeader from './SearchPageHeader';
-import type {SearchColumnType, SearchQueryJSON, SearchStatus, SelectedTransactionInfo, SelectedTransactions, SortOrder} from './types';
+import type {ExpenseSearchStatus, SearchColumnType, SearchQueryJSON, SelectedTransactionInfo, SelectedTransactions, SortOrder} from './types';
 
 type SearchProps = {
     queryJSON: SearchQueryJSON;
@@ -43,7 +43,7 @@ const transactionItemMobileHeight = 100;
 const reportItemTransactionHeight = 52;
 const listItemPadding = 12; // this is equivalent to 'mb3' on every transaction/report list item
 const searchHeaderHeight = 54;
-const sortableSearchStatuses: SearchStatus[] = [CONST.SEARCH.STATUS.ALL];
+const sortableSearchStatuses: ExpenseSearchStatus[] = [CONST.SEARCH.STATUS.EXPENSE.ALL];
 
 function mapTransactionItemToSelectedEntry(item: TransactionListItemType): [string, SelectedTransactionInfo] {
     return [item.keyForList, {isSelected: true, canDelete: item.canDelete, canHold: item.canHold, canUnhold: item.canUnhold, action: item.action}];
diff --git a/src/components/Search/types.ts b/src/components/Search/types.ts
index 96b9b3063b48..8998aa780c77 100644
--- a/src/components/Search/types.ts
+++ b/src/components/Search/types.ts
@@ -24,7 +24,7 @@ type SelectedTransactions = Record<string, SelectedTransactionInfo>;
 
 type SortOrder = ValueOf<typeof CONST.SEARCH.SORT_ORDER>;
 type SearchColumnType = ValueOf<typeof CONST.SEARCH.TABLE_COLUMNS>;
-type SearchStatus = ValueOf<typeof CONST.SEARCH.STATUS>;
+type ExpenseSearchStatus = ValueOf<typeof CONST.SEARCH.STATUS.EXPENSE>;
 
 type SearchContext = {
     currentSearchHash: number;
@@ -55,7 +55,7 @@ type SearchQueryString = string;
 
 type SearchQueryAST = {
     type: string;
-    status: SearchStatus;
+    status: ExpenseSearchStatus;
     sortBy: SearchColumnType;
     sortOrder: SortOrder;
     filters: ASTNode;
@@ -70,7 +70,7 @@ export type {
     SelectedTransactionInfo,
     SelectedTransactions,
     SearchColumnType,
-    SearchStatus,
+    ExpenseSearchStatus,
     SearchQueryAST,
     SearchQueryJSON,
     SearchQueryString,
diff --git a/src/libs/API/parameters/ExportSearchItemsToCSVParams.ts b/src/libs/API/parameters/ExportSearchItemsToCSVParams.ts
index 2659fac6810a..5c0143719e8a 100644
--- a/src/libs/API/parameters/ExportSearchItemsToCSVParams.ts
+++ b/src/libs/API/parameters/ExportSearchItemsToCSVParams.ts
@@ -1,7 +1,7 @@
-import type {SearchStatus} from '@components/Search/types';
+import type {ExpenseSearchStatus} from '@components/Search/types';
 
 type ExportSearchItemsToCSVParams = {
-    query: SearchStatus;
+    query: ExpenseSearchStatus;
     reportIDList: string[];
     transactionIDList: string[];
     policyIDs: string[];
diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts
index c04a6ecedc40..07cccabba082 100644
--- a/src/libs/SearchUtils.ts
+++ b/src/libs/SearchUtils.ts
@@ -97,6 +97,18 @@ function getShouldShowMerchant(data: OnyxTypes.SearchResults['data']): boolean {
 
 const currentYear = new Date().getFullYear();
 
+function getExpenseListItem(status) {
+    return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? TransactionListItem : ReportListItem;
+}
+
+function getExpenseSections(status) {
+    return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? getTransactionsSections : getReportSections;
+}
+
+function getSortedExpenseData(status) {
+    return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? getSortedTransactionData : getSortedReportData;
+}
+
 function isReportListItemType(item: ListItem): item is ReportListItemType {
     return 'transactions' in item;
 }
diff --git a/src/pages/Search/SearchFiltersStatusPage.tsx b/src/pages/Search/SearchFiltersStatusPage.tsx
index 8cc58f0304ee..fca6faa6fd0c 100644
--- a/src/pages/Search/SearchFiltersStatusPage.tsx
+++ b/src/pages/Search/SearchFiltersStatusPage.tsx
@@ -27,27 +27,27 @@ function SearchFiltersStatusPage() {
         () => [
             {
                 text: translate('common.all'),
-                value: CONST.SEARCH.STATUS.ALL,
-                keyForList: CONST.SEARCH.STATUS.ALL,
-                isSelected: activeItem === CONST.SEARCH.STATUS.ALL,
+                value: CONST.SEARCH.STATUS.EXPENSE.ALL,
+                keyForList: CONST.SEARCH.STATUS.EXPENSE.ALL,
+                isSelected: activeItem === CONST.SEARCH.STATUS.EXPENSE.ALL,
             },
             {
                 text: translate('common.shared'),
-                value: CONST.SEARCH.STATUS.SHARED,
-                keyForList: CONST.SEARCH.STATUS.SHARED,
-                isSelected: activeItem === CONST.SEARCH.STATUS.SHARED,
+                value: CONST.SEARCH.STATUS.EXPENSE.SHARED,
+                keyForList: CONST.SEARCH.STATUS.EXPENSE.SHARED,
+                isSelected: activeItem === CONST.SEARCH.STATUS.EXPENSE.SHARED,
             },
             {
                 text: translate('common.drafts'),
-                value: CONST.SEARCH.STATUS.DRAFTS,
-                keyForList: CONST.SEARCH.STATUS.DRAFTS,
-                isSelected: activeItem === CONST.SEARCH.STATUS.DRAFTS,
+                value: CONST.SEARCH.STATUS.EXPENSE.DRAFTS,
+                keyForList: CONST.SEARCH.STATUS.EXPENSE.DRAFTS,
+                isSelected: activeItem === CONST.SEARCH.STATUS.EXPENSE.DRAFTS,
             },
             {
                 text: translate('common.finished'),
-                value: CONST.SEARCH.STATUS.FINISHED,
-                keyForList: CONST.SEARCH.STATUS.FINISHED,
-                isSelected: activeItem === CONST.SEARCH.STATUS.FINISHED,
+                value: CONST.SEARCH.STATUS.EXPENSE.FINISHED,
+                keyForList: CONST.SEARCH.STATUS.EXPENSE.FINISHED,
+                isSelected: activeItem === CONST.SEARCH.STATUS.EXPENSE.FINISHED,
             },
         ],
         [translate, activeItem],
diff --git a/src/pages/Search/SearchStatusMenu.tsx b/src/pages/Search/SearchStatusMenu.tsx
index 9b8e890bbefd..493d277e5e40 100644
--- a/src/pages/Search/SearchStatusMenu.tsx
+++ b/src/pages/Search/SearchStatusMenu.tsx
@@ -1,7 +1,7 @@
 import React from 'react';
 import {View} from 'react-native';
 import MenuItem from '@components/MenuItem';
-import type {SearchQueryJSON, SearchStatus} from '@components/Search/types';
+import type {ExpenseSearchStatus, SearchQueryJSON} from '@components/Search/types';
 import useLocalize from '@hooks/useLocalize';
 import useResponsiveLayout from '@hooks/useResponsiveLayout';
 import useSingleExecution from '@hooks/useSingleExecution';
@@ -24,7 +24,7 @@ type SearchStatusMenuProps = {
 
 type SearchStatusMenuItem = {
     title: string;
-    status: SearchStatus;
+    status: ExpenseSearchStatus;
     icon: IconAsset;
     route?: Route;
 };
@@ -39,25 +39,25 @@ function SearchStatusMenu({queryJSON, isCustomQuery}: SearchStatusMenuProps) {
     const statusMenuItems: SearchStatusMenuItem[] = [
         {
             title: translate('common.expenses'),
-            status: CONST.SEARCH.STATUS.ALL,
+            status: CONST.SEARCH.STATUS.EXPENSE.ALL,
             icon: Expensicons.Receipt,
             route: ROUTES.SEARCH_CENTRAL_PANE.getRoute({query: normalizeQuery(CONST.SEARCH.TAB.EXPENSE.ALL)}),
         },
         {
             title: translate('common.shared'),
-            status: CONST.SEARCH.STATUS.SHARED,
+            status: CONST.SEARCH.STATUS.EXPENSE.SHARED,
             icon: Expensicons.Send,
             route: ROUTES.SEARCH_CENTRAL_PANE.getRoute({query: normalizeQuery(CONST.SEARCH.TAB.EXPENSE.SHARED)}),
         },
         {
             title: translate('common.drafts'),
-            status: CONST.SEARCH.STATUS.DRAFTS,
+            status: CONST.SEARCH.STATUS.EXPENSE.DRAFTS,
             icon: Expensicons.Pencil,
             route: ROUTES.SEARCH_CENTRAL_PANE.getRoute({query: normalizeQuery(CONST.SEARCH.TAB.EXPENSE.DRAFTS)}),
         },
         {
             title: translate('common.finished'),
-            status: CONST.SEARCH.STATUS.FINISHED,
+            status: CONST.SEARCH.STATUS.EXPENSE.FINISHED,
             icon: Expensicons.CheckCircle,
             route: ROUTES.SEARCH_CENTRAL_PANE.getRoute({query: normalizeQuery(CONST.SEARCH.TAB.EXPENSE.FINISHED)}),
         },

From 4a3a02e3efed08e3ede03eb526910319a5b46d54 Mon Sep 17 00:00:00 2001
From: Carlos Martins <cmartins@expensify.com>
Date: Thu, 8 Aug 2024 20:24:04 +0300
Subject: [PATCH 2/3] implement get methods

---
 src/CONST.ts            |  1 +
 src/libs/SearchUtils.ts | 13 +++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/CONST.ts b/src/CONST.ts
index 395797957238..b2748765f54d 100755
--- a/src/CONST.ts
+++ b/src/CONST.ts
@@ -5240,6 +5240,7 @@ const CONST = {
         DATA_TYPES: {
             TRANSACTION: 'transaction',
             REPORT: 'report',
+            EXPENSE: 'expense',
         },
         ACTION_TYPES: {
             VIEW: 'view',
diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts
index 07cccabba082..f78f4bc9ac1c 100644
--- a/src/libs/SearchUtils.ts
+++ b/src/libs/SearchUtils.ts
@@ -1,5 +1,5 @@
 import type {ValueOf} from 'type-fest';
-import type {ASTNode, QueryFilter, QueryFilters, SearchColumnType, SearchQueryJSON, SearchQueryString, SortOrder} from '@components/Search/types';
+import type {ASTNode, ExpenseSearchStatus, QueryFilter, QueryFilters, SearchColumnType, SearchQueryJSON, SearchQueryString, SortOrder} from '@components/Search/types';
 import ReportListItem from '@components/SelectionList/Search/ReportListItem';
 import TransactionListItem from '@components/SelectionList/Search/TransactionListItem';
 import type {ListItem, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types';
@@ -97,15 +97,15 @@ function getShouldShowMerchant(data: OnyxTypes.SearchResults['data']): boolean {
 
 const currentYear = new Date().getFullYear();
 
-function getExpenseListItem(status) {
+function getExpenseListItem(status: ExpenseSearchStatus) {
     return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? TransactionListItem : ReportListItem;
 }
 
-function getExpenseSections(status) {
+function getExpenseSections(status: ExpenseSearchStatus) {
     return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? getTransactionsSections : getReportSections;
 }
 
-function getSortedExpenseData(status) {
+function getSortedExpenseData(status: ExpenseSearchStatus) {
     return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? getSortedTransactionData : getSortedReportData;
 }
 
@@ -257,6 +257,11 @@ const searchTypeToItemMap: SearchTypeToItemMap = {
         // sorting for ReportItems not yet implemented
         getSortedSections: getSortedReportData,
     },
+    [CONST.SEARCH.DATA_TYPES.EXPENSE]: {
+        listItem: getExpenseListItem,
+        getSections: getExpenseSections,
+        getSortedSections: getSortedExpenseData,
+    },
 };
 
 function getListItem<K extends keyof SearchTypeToItemMap>(type: K): SearchTypeToItemMap[K]['listItem'] {

From c84be8ace9c738c6037bfaafb97c929f3cf0f61a Mon Sep 17 00:00:00 2001
From: Carlos Martins <cmartins@expensify.com>
Date: Thu, 8 Aug 2024 21:29:50 +0300
Subject: [PATCH 3/3] rfactor code

---
 src/components/Search/SearchPageHeader.tsx    |  4 +-
 src/components/Search/index.tsx               | 10 +--
 src/components/Search/types.ts                |  5 +-
 .../ExportSearchItemsToCSVParams.ts           |  4 +-
 src/libs/SearchUtils.ts                       | 79 ++++++++-----------
 src/pages/Search/SearchStatusMenu.tsx         |  4 +-
 src/types/onyx/SearchResults.ts               | 28 ++-----
 7 files changed, 52 insertions(+), 82 deletions(-)

diff --git a/src/components/Search/SearchPageHeader.tsx b/src/components/Search/SearchPageHeader.tsx
index b0f05e6d648a..039526923b3a 100644
--- a/src/components/Search/SearchPageHeader.tsx
+++ b/src/components/Search/SearchPageHeader.tsx
@@ -31,7 +31,7 @@ import type {SearchReport} from '@src/types/onyx/SearchResults';
 import type DeepValueOf from '@src/types/utils/DeepValueOf';
 import type IconAsset from '@src/types/utils/IconAsset';
 import {useSearchContext} from './SearchContext';
-import type {ExpenseSearchStatus, SearchQueryJSON} from './types';
+import type {SearchQueryJSON, SearchStatus} from './types';
 
 type HeaderWrapperProps = Pick<HeaderWithBackButtonProps, 'title' | 'subtitle' | 'icon' | 'children'> & {
     subtitleStyles?: StyleProp<TextStyle>;
@@ -100,7 +100,7 @@ type SearchPageHeaderProps = {
 
 type SearchHeaderOptionValue = DeepValueOf<typeof CONST.SEARCH.BULK_ACTION_TYPES> | undefined;
 
-const headerContent: {[key in ExpenseSearchStatus]: {icon: IconAsset; titleTx: TranslationPaths}} = {
+const headerContent: {[key in SearchStatus]: {icon: IconAsset; titleTx: TranslationPaths}} = {
     all: {icon: Illustrations.MoneyReceipts, titleTx: 'common.expenses'},
     shared: {icon: Illustrations.SendMoney, titleTx: 'common.shared'},
     drafts: {icon: Illustrations.Pencil, titleTx: 'common.drafts'},
diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx
index 2109fa969622..873c051aaa95 100644
--- a/src/components/Search/index.tsx
+++ b/src/components/Search/index.tsx
@@ -31,7 +31,7 @@ import ROUTES from '@src/ROUTES';
 import type SearchResults from '@src/types/onyx/SearchResults';
 import {useSearchContext} from './SearchContext';
 import SearchPageHeader from './SearchPageHeader';
-import type {ExpenseSearchStatus, SearchColumnType, SearchQueryJSON, SelectedTransactionInfo, SelectedTransactions, SortOrder} from './types';
+import type {SearchColumnType, SearchQueryJSON, SearchStatus, SelectedTransactionInfo, SelectedTransactions, SortOrder} from './types';
 
 type SearchProps = {
     queryJSON: SearchQueryJSON;
@@ -43,7 +43,7 @@ const transactionItemMobileHeight = 100;
 const reportItemTransactionHeight = 52;
 const listItemPadding = 12; // this is equivalent to 'mb3' on every transaction/report list item
 const searchHeaderHeight = 54;
-const sortableSearchStatuses: ExpenseSearchStatus[] = [CONST.SEARCH.STATUS.EXPENSE.ALL];
+const sortableSearchStatuses: SearchStatus[] = [CONST.SEARCH.STATUS.EXPENSE.ALL];
 
 function mapTransactionItemToSelectedEntry(item: TransactionListItemType): [string, SelectedTransactionInfo] {
     return [item.keyForList, {isSelected: true, canDelete: item.canDelete, canHold: item.canHold, canUnhold: item.canUnhold, action: item.action}];
@@ -208,9 +208,9 @@ function Search({queryJSON, policyIDs, isCustomQuery}: SearchProps) {
         return null;
     }
 
-    const ListItem = SearchUtils.getListItem(type);
-    const data = SearchUtils.getSections(searchResults.data, searchResults.search, type);
-    const sortedData = SearchUtils.getSortedSections(type, data, sortBy, sortOrder);
+    const ListItem = SearchUtils.getListItem(type, status);
+    const data = SearchUtils.getSections(type, status, searchResults.data, searchResults.search);
+    const sortedData = SearchUtils.getSortedSections(type, status, data, sortBy, sortOrder);
     const sortedSelectedData = sortedData.map((item) => mapToItemWithSelectionInfo(item, selectedTransactions));
 
     const shouldShowEmptyState = !isDataLoaded || data.length === 0;
diff --git a/src/components/Search/types.ts b/src/components/Search/types.ts
index 8998aa780c77..54b26ea6bac4 100644
--- a/src/components/Search/types.ts
+++ b/src/components/Search/types.ts
@@ -25,6 +25,7 @@ type SelectedTransactions = Record<string, SelectedTransactionInfo>;
 type SortOrder = ValueOf<typeof CONST.SEARCH.SORT_ORDER>;
 type SearchColumnType = ValueOf<typeof CONST.SEARCH.TABLE_COLUMNS>;
 type ExpenseSearchStatus = ValueOf<typeof CONST.SEARCH.STATUS.EXPENSE>;
+type SearchStatus = ExpenseSearchStatus;
 
 type SearchContext = {
     currentSearchHash: number;
@@ -55,7 +56,7 @@ type SearchQueryString = string;
 
 type SearchQueryAST = {
     type: string;
-    status: ExpenseSearchStatus;
+    status: SearchStatus;
     sortBy: SearchColumnType;
     sortOrder: SortOrder;
     filters: ASTNode;
@@ -70,7 +71,7 @@ export type {
     SelectedTransactionInfo,
     SelectedTransactions,
     SearchColumnType,
-    ExpenseSearchStatus,
+    SearchStatus,
     SearchQueryAST,
     SearchQueryJSON,
     SearchQueryString,
diff --git a/src/libs/API/parameters/ExportSearchItemsToCSVParams.ts b/src/libs/API/parameters/ExportSearchItemsToCSVParams.ts
index 5c0143719e8a..2659fac6810a 100644
--- a/src/libs/API/parameters/ExportSearchItemsToCSVParams.ts
+++ b/src/libs/API/parameters/ExportSearchItemsToCSVParams.ts
@@ -1,7 +1,7 @@
-import type {ExpenseSearchStatus} from '@components/Search/types';
+import type {SearchStatus} from '@components/Search/types';
 
 type ExportSearchItemsToCSVParams = {
-    query: ExpenseSearchStatus;
+    query: SearchStatus;
     reportIDList: string[];
     transactionIDList: string[];
     policyIDs: string[];
diff --git a/src/libs/SearchUtils.ts b/src/libs/SearchUtils.ts
index f78f4bc9ac1c..9d2782acb792 100644
--- a/src/libs/SearchUtils.ts
+++ b/src/libs/SearchUtils.ts
@@ -1,5 +1,5 @@
 import type {ValueOf} from 'type-fest';
-import type {ASTNode, ExpenseSearchStatus, QueryFilter, QueryFilters, SearchColumnType, SearchQueryJSON, SearchQueryString, SortOrder} from '@components/Search/types';
+import type {ASTNode, QueryFilter, QueryFilters, SearchColumnType, SearchQueryJSON, SearchQueryString, SearchStatus, SortOrder} from '@components/Search/types';
 import ReportListItem from '@components/SelectionList/Search/ReportListItem';
 import TransactionListItem from '@components/SelectionList/Search/TransactionListItem';
 import type {ListItem, ReportListItemType, TransactionListItemType} from '@components/SelectionList/types';
@@ -10,7 +10,7 @@ import type {SearchAdvancedFiltersForm} from '@src/types/form';
 import INPUT_IDS from '@src/types/form/SearchAdvancedFiltersForm';
 import type * as OnyxTypes from '@src/types/onyx';
 import type SearchResults from '@src/types/onyx/SearchResults';
-import type {SearchAccountDetails, SearchDataTypes, SearchPersonalDetails, SearchTransaction, SearchTypeToItemMap, SectionsType} from '@src/types/onyx/SearchResults';
+import type {ListItemDataType, ListItemType, SearchAccountDetails, SearchDataTypes, SearchPersonalDetails, SearchTransaction} from '@src/types/onyx/SearchResults';
 import DateUtils from './DateUtils';
 import navigationRef from './Navigation/navigationRef';
 import type {AuthScreensParamList, BottomTabNavigatorParamList, RootStackParamList, State} from './Navigation/types';
@@ -97,18 +97,6 @@ function getShouldShowMerchant(data: OnyxTypes.SearchResults['data']): boolean {
 
 const currentYear = new Date().getFullYear();
 
-function getExpenseListItem(status: ExpenseSearchStatus) {
-    return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? TransactionListItem : ReportListItem;
-}
-
-function getExpenseSections(status: ExpenseSearchStatus) {
-    return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? getTransactionsSections : getReportSections;
-}
-
-function getSortedExpenseData(status: ExpenseSearchStatus) {
-    return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? getSortedTransactionData : getSortedReportData;
-}
-
 function isReportListItemType(item: ListItem): item is ReportListItemType {
     return 'transactions' in item;
 }
@@ -245,44 +233,39 @@ function getReportSections(data: OnyxTypes.SearchResults['data'], metadata: Onyx
     return Object.values(reportIDToTransactions);
 }
 
-const searchTypeToItemMap: SearchTypeToItemMap = {
-    [CONST.SEARCH.DATA_TYPES.TRANSACTION]: {
-        listItem: TransactionListItem,
-        getSections: getTransactionsSections,
-        getSortedSections: getSortedTransactionData,
-    },
-    [CONST.SEARCH.DATA_TYPES.REPORT]: {
-        listItem: ReportListItem,
-        getSections: getReportSections,
-        // sorting for ReportItems not yet implemented
-        getSortedSections: getSortedReportData,
-    },
-    [CONST.SEARCH.DATA_TYPES.EXPENSE]: {
-        listItem: getExpenseListItem,
-        getSections: getExpenseSections,
-        getSortedSections: getSortedExpenseData,
-    },
-};
-
-function getListItem<K extends keyof SearchTypeToItemMap>(type: K): SearchTypeToItemMap[K]['listItem'] {
-    return searchTypeToItemMap[type].listItem;
+function getListItem(type: SearchDataTypes, status: SearchStatus): ListItemType<typeof status> {
+    switch (type) {
+        case CONST.SEARCH.DATA_TYPES.TRANSACTION:
+        case CONST.SEARCH.DATA_TYPES.EXPENSE:
+        case CONST.SEARCH.DATA_TYPES.REPORT:
+            return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? TransactionListItem : ReportListItem;
+        default:
+            return TransactionListItem;
+    }
 }
 
-function getSections<K extends keyof SearchTypeToItemMap>(
-    data: OnyxTypes.SearchResults['data'],
-    metadata: OnyxTypes.SearchResults['search'],
-    type: K,
-): ReturnType<SearchTypeToItemMap[K]['getSections']> {
-    return searchTypeToItemMap[type].getSections(data, metadata) as ReturnType<SearchTypeToItemMap[K]['getSections']>;
+function getSections(type: SearchDataTypes, status: SearchStatus, data: OnyxTypes.SearchResults['data'], metadata: OnyxTypes.SearchResults['search']) {
+    switch (type) {
+        case CONST.SEARCH.DATA_TYPES.TRANSACTION:
+        case CONST.SEARCH.DATA_TYPES.EXPENSE:
+        case CONST.SEARCH.DATA_TYPES.REPORT:
+            return status === CONST.SEARCH.STATUS.EXPENSE.ALL ? getTransactionsSections(data, metadata) : getReportSections(data, metadata);
+        default:
+            return getTransactionsSections(data, metadata);
+    }
 }
 
-function getSortedSections<K extends keyof SearchTypeToItemMap>(
-    type: K,
-    data: SectionsType<K>,
-    sortBy?: SearchColumnType,
-    sortOrder?: SortOrder,
-): ReturnType<SearchTypeToItemMap[K]['getSortedSections']> {
-    return searchTypeToItemMap[type].getSortedSections(data, sortBy, sortOrder) as ReturnType<SearchTypeToItemMap[K]['getSortedSections']>;
+function getSortedSections(type: SearchDataTypes, status: SearchStatus, data: ListItemDataType<typeof status>, sortBy?: SearchColumnType, sortOrder?: SortOrder) {
+    switch (type) {
+        case CONST.SEARCH.DATA_TYPES.TRANSACTION:
+        case CONST.SEARCH.DATA_TYPES.EXPENSE:
+        case CONST.SEARCH.DATA_TYPES.REPORT:
+            return status === CONST.SEARCH.STATUS.EXPENSE.ALL
+                ? getSortedTransactionData(data as TransactionListItemType[], sortBy, sortOrder)
+                : getSortedReportData(data as ReportListItemType[]);
+        default:
+            return getSortedTransactionData(data as TransactionListItemType[], sortBy, sortOrder);
+    }
 }
 
 function getQueryHash(query: string, policyID?: string, sortBy?: string, sortOrder?: string): number {
diff --git a/src/pages/Search/SearchStatusMenu.tsx b/src/pages/Search/SearchStatusMenu.tsx
index 493d277e5e40..9fd812ead9a1 100644
--- a/src/pages/Search/SearchStatusMenu.tsx
+++ b/src/pages/Search/SearchStatusMenu.tsx
@@ -1,7 +1,7 @@
 import React from 'react';
 import {View} from 'react-native';
 import MenuItem from '@components/MenuItem';
-import type {ExpenseSearchStatus, SearchQueryJSON} from '@components/Search/types';
+import type {SearchQueryJSON, SearchStatus} from '@components/Search/types';
 import useLocalize from '@hooks/useLocalize';
 import useResponsiveLayout from '@hooks/useResponsiveLayout';
 import useSingleExecution from '@hooks/useSingleExecution';
@@ -24,7 +24,7 @@ type SearchStatusMenuProps = {
 
 type SearchStatusMenuItem = {
     title: string;
-    status: ExpenseSearchStatus;
+    status: SearchStatus;
     icon: IconAsset;
     route?: Route;
 };
diff --git a/src/types/onyx/SearchResults.ts b/src/types/onyx/SearchResults.ts
index 94fb182a4ad9..f1fe92fdcac9 100644
--- a/src/types/onyx/SearchResults.ts
+++ b/src/types/onyx/SearchResults.ts
@@ -1,5 +1,5 @@
 import type {ValueOf} from 'type-fest';
-import type {SearchColumnType, SortOrder} from '@components/Search/types';
+import type {SearchStatus} from '@components/Search/types';
 import type ReportListItem from '@components/SelectionList/Search/ReportListItem';
 import type TransactionListItem from '@components/SelectionList/Search/TransactionListItem';
 import type {ReportListItemType, TransactionListItemType} from '@components/SelectionList/types';
@@ -9,11 +9,10 @@ import type CONST from '@src/CONST';
 type SearchDataTypes = ValueOf<typeof CONST.SEARCH.DATA_TYPES>;
 
 /** Model of search result list item */
-type ListItemType<T extends SearchDataTypes> = T extends typeof CONST.SEARCH.DATA_TYPES.TRANSACTION
-    ? typeof TransactionListItem
-    : T extends typeof CONST.SEARCH.DATA_TYPES.REPORT
-    ? typeof ReportListItem
-    : never;
+type ListItemType<T extends SearchStatus> = T extends typeof CONST.SEARCH.STATUS.EXPENSE.ALL ? typeof TransactionListItem : typeof ReportListItem;
+
+/** Model of search list item data type */
+type ListItemDataType<T extends SearchStatus> = T extends typeof CONST.SEARCH.STATUS.EXPENSE.ALL ? TransactionListItemType[] : ReportListItemType[];
 
 /** Model of search result section */
 type SectionsType<T extends SearchDataTypes> = T extends typeof CONST.SEARCH.DATA_TYPES.TRANSACTION
@@ -22,20 +21,6 @@ type SectionsType<T extends SearchDataTypes> = T extends typeof CONST.SEARCH.DAT
     ? ReportListItemType[]
     : never;
 
-/** Mapping of search results to list item */
-type SearchTypeToItemMap = {
-    [K in SearchDataTypes]: {
-        /** Collection of search result list item */
-        listItem: ListItemType<K>;
-
-        /** Returns search results sections based on search results data */
-        getSections: (data: SearchResults['data'], metadata: SearchResults['search']) => SectionsType<K>;
-
-        /** Returns sorted search results sections based on search results data */
-        getSortedSections: (data: SectionsType<K>, sortBy?: SearchColumnType, sortOrder?: SortOrder) => SectionsType<K>;
-    };
-};
-
 /** Model of columns to show for search results */
 type ColumnsToShow = {
     /** Whether the category column should be shown */
@@ -258,6 +243,8 @@ type SearchResults = {
 export default SearchResults;
 
 export type {
+    ListItemType,
+    ListItemDataType,
     SearchTransaction,
     SearchTransactionType,
     SearchTransactionAction,
@@ -265,7 +252,6 @@ export type {
     SearchPolicyDetails,
     SearchAccountDetails,
     SearchDataTypes,
-    SearchTypeToItemMap,
     SearchReport,
     SectionsType,
 };
