diff --git a/src/CONST.ts b/src/CONST.ts index d2be946cdb2b..e9d4acf50fcf 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -4782,6 +4782,7 @@ const CONST = { SEARCH_DATA_TYPES: { TRANSACTION: 'transaction', + REPORT: 'report', }, REFERRER: { diff --git a/src/components/Search.tsx b/src/components/Search.tsx index b4dcc9a15d75..4cead436aae2 100644 --- a/src/components/Search.tsx +++ b/src/components/Search.tsx @@ -15,6 +15,7 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject'; import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; import SelectionList from './SelectionList'; import SearchTableHeader from './SelectionList/SearchTableHeader'; +import type {ReportListItemType, TransactionListItemType} from './SelectionList/types'; import TableListItemSkeleton from './Skeletons/TableListItemSkeleton'; type SearchProps = { @@ -22,6 +23,11 @@ type SearchProps = { policyIDs?: string; }; +function isReportListItemType(item: TransactionListItemType | ReportListItemType): item is ReportListItemType { + const reportListItem = item as ReportListItemType; + return reportListItem.transactions !== undefined; +} + function Search({query, policyIDs}: SearchProps) { const {isOffline} = useNetwork(); const styles = useThemeStyles(); @@ -74,10 +80,11 @@ function Search({query, policyIDs}: SearchProps) { } const ListItem = SearchUtils.getListItem(type); + const data = SearchUtils.getSections(searchResults?.data ?? {}, type); return ( - customListHeader={} // To enhance the smoothness of scrolling and minimize the risk of encountering blank spaces during scrolling, // we have configured a larger windowSize and a longer delay between batch renders. @@ -93,7 +100,9 @@ function Search({query, policyIDs}: SearchProps) { ListItem={ListItem} sections={[{data, isDisabled: false}]} onSelectRow={(item) => { - openReport(item.transactionThreadReportID); + const reportID = isReportListItemType(item) ? item.reportID : item.transactionThreadReportID; + + openReport(reportID); }} shouldPreventDefaultFocusOnSelectRow={!DeviceCapabilities.canUseTouchScreen()} listHeaderWrapperStyle={[styles.ph9, styles.pv3, styles.pb5]} diff --git a/src/components/SelectionList/Search/ExpenseItemHeaderNarrow.tsx b/src/components/SelectionList/Search/ExpenseItemHeaderNarrow.tsx new file mode 100644 index 000000000000..9b2188c659e5 --- /dev/null +++ b/src/components/SelectionList/Search/ExpenseItemHeaderNarrow.tsx @@ -0,0 +1,54 @@ +import React, {memo} from 'react'; +import {View} from 'react-native'; +import Button from '@components/Button'; +import Icon from '@components/Icon'; +import * as Expensicons from '@components/Icon/Expensicons'; +import useStyleUtils from '@hooks/useStyleUtils'; +import useTheme from '@hooks/useTheme'; +import useThemeStyles from '@hooks/useThemeStyles'; +import variables from '@styles/variables'; +import type {SearchAccountDetails} from '@src/types/onyx/SearchResults'; +import UserInfoCell from './UserInfoCell'; + +type ExpenseItemHeaderNarrowProps = { + participantFrom: SearchAccountDetails; + participantTo: SearchAccountDetails; + buttonText: string; + onButtonPress: () => void; +}; + +function ExpenseItemHeaderNarrow({participantFrom, participantTo, buttonText, onButtonPress}: ExpenseItemHeaderNarrowProps) { + const styles = useThemeStyles(); + const StyleUtils = useStyleUtils(); + const theme = useTheme(); + + return ( + + + + + + + + + + + +