From 44f2a475ec2847ac6edbdfc72effc5c11c800855 Mon Sep 17 00:00:00 2001 From: Chuck Dries Date: Thu, 13 Nov 2025 10:16:18 -0800 Subject: [PATCH] Revert "Add report columns" --- src/CONST/index.ts | 3 - .../SearchPageHeader/SearchFiltersBar.tsx | 25 +-- src/components/Search/index.tsx | 6 +- .../Search/ExpenseReportListItem.tsx | 127 ----------- .../Search/ExpenseReportListItemRow.tsx | 208 ------------------ .../Search/StatusCell.tsx | 47 ---- .../Search/TitleCell.tsx | 22 -- .../Search/TransactionGroupListExpanded.tsx | 2 +- .../SearchTableHeader.tsx | 45 +--- .../SortableHeaderText.tsx | 52 ++--- .../SortableTableHeader.tsx | 5 +- .../SelectionListWithSections/types.ts | 29 +-- src/languages/de.ts | 1 - src/languages/en.ts | 1 - src/languages/es.ts | 1 - src/languages/fr.ts | 1 - src/languages/it.ts | 1 - src/languages/ja.ts | 1 - src/languages/nl.ts | 1 - src/languages/pl.ts | 1 - src/languages/pt-BR.ts | 1 - src/languages/zh-hans.ts | 1 - src/libs/SearchUIUtils.ts | 119 ++-------- src/styles/utils/index.ts | 7 - src/styles/variables.ts | 3 - tests/unit/Search/SearchUIUtilsTest.ts | 29 +-- .../Search/handleActionButtonPressTest.ts | 1 - tests/unit/TransactionGroupListItemTest.tsx | 1 - 28 files changed, 53 insertions(+), 688 deletions(-) delete mode 100644 src/components/SelectionListWithSections/Search/ExpenseReportListItem.tsx delete mode 100644 src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx delete mode 100644 src/components/SelectionListWithSections/Search/StatusCell.tsx delete mode 100644 src/components/SelectionListWithSections/Search/TitleCell.tsx diff --git a/src/CONST/index.ts b/src/CONST/index.ts index c146e5608c62..5a0fe86933af 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -6661,7 +6661,6 @@ const CONST = { CATEGORY: 'category', TAG: 'tag', TOTAL_AMOUNT: 'amount', - TOTAL: 'total', TYPE: 'type', ACTION: 'action', TAX_AMOUNT: 'taxAmount', @@ -6671,8 +6670,6 @@ const CONST = { COMMENTS: 'comments', CARD: 'card', WITHDRAWAL_ID: 'withdrawalID', - AVATAR: 'avatar', - STATUS: 'status', }, SYNTAX_OPERATORS: { AND: 'and', diff --git a/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx b/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx index 5697a01cf347..aef844e14ffe 100644 --- a/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx +++ b/src/components/Search/SearchPageHeader/SearchFiltersBar.tsx @@ -136,27 +136,6 @@ function SearchFiltersBar({ return [options, value]; }, [allPolicies, email, unsafeType]); - const isExpenseReportType = useMemo(() => type?.value === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT, [type]); - - const selectedItemsCount = useMemo(() => { - if (!selectedTransactions) { - return 0; - } - - if (isExpenseReportType) { - // In expense report mode, count unique reports instead of individual transactions - const reportIDs = new Set( - Object.values(selectedTransactions) - .map((transaction) => transaction?.reportID) - .filter((reportID): reportID is string => !!reportID), - ); - return reportIDs.size; - } - - // Otherwise count transactions - return selectedTransactionsKeys.length; - }, [selectedTransactions, isExpenseReportType, selectedTransactionsKeys.length]); - const [groupByOptions, groupBy] = useMemo(() => { const options = getGroupByOptions(); const value = options.find((option) => option.value === unsafeGroupBy) ?? null; @@ -683,7 +662,9 @@ function SearchFiltersBar({ return ; } - const selectionButtonText = areAllMatchingItemsSelected ? translate('search.exportAll.allMatchingItemsSelected') : translate('workspace.common.selected', {count: selectedItemsCount}); + const selectionButtonText = areAllMatchingItemsSelected + ? translate('search.exportAll.allMatchingItemsSelected') + : translate('workspace.common.selected', {count: selectedTransactionsKeys.length}); return ( diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 1096bb3cca8e..de68be1c5f51 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -719,7 +719,7 @@ function Search({ if (!searchResults?.data) { return []; } - const columns = getColumnsToShow(accountID, searchResults?.data, false, searchResults?.search?.type); + const columns = getColumnsToShow(accountID, searchResults?.data, false, searchResults?.search?.type === CONST.SEARCH.DATA_TYPES.TASK); return (Object.keys(columns) as SearchColumnType[]).filter((col) => columns[col]); }, [accountID, searchResults?.data, searchResults?.search?.type]); @@ -897,10 +897,10 @@ function Search({ navigation.setParams({q: newQuery}); }; - const shouldShowYear = shouldShowYearUtil(searchResults?.data, isExpenseReportType ?? false); + const shouldShowYear = shouldShowYearUtil(searchResults?.data); const {shouldShowAmountInWideColumn, shouldShowTaxAmountInWideColumn} = getWideAmountIndicators(searchResults?.data); const shouldShowSorting = !validGroupBy; - const shouldShowTableHeader = isLargeScreenWidth && !isChat && !validGroupBy; + const shouldShowTableHeader = isLargeScreenWidth && !isChat && !validGroupBy && !isExpenseReportType; const tableHeaderVisible = (canSelectMultiple || shouldShowTableHeader) && (!validGroupBy || isExpenseReportType); return ( diff --git a/src/components/SelectionListWithSections/Search/ExpenseReportListItem.tsx b/src/components/SelectionListWithSections/Search/ExpenseReportListItem.tsx deleted file mode 100644 index fe98578e688f..000000000000 --- a/src/components/SelectionListWithSections/Search/ExpenseReportListItem.tsx +++ /dev/null @@ -1,127 +0,0 @@ -import React, {useCallback, useMemo} from 'react'; -import {useSearchContext} from '@components/Search/SearchContext'; -import BaseListItem from '@components/SelectionListWithSections/BaseListItem'; -import type {ExpenseReportListItemProps, ExpenseReportListItemType, ListItem} from '@components/SelectionListWithSections/types'; -import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; -import useOnyx from '@hooks/useOnyx'; -import useResponsiveLayout from '@hooks/useResponsiveLayout'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; -import {handleActionButtonPress} from '@libs/actions/Search'; -import variables from '@styles/variables'; -import ONYXKEYS from '@src/ONYXKEYS'; -import type {Policy} from '@src/types/onyx'; -import type {SearchReport} from '@src/types/onyx/SearchResults'; -import ExpenseReportListItemRow from './ExpenseReportListItemRow'; - -function ExpenseReportListItem({ - item, - isLoading, - isFocused, - showTooltip, - isDisabled, - canSelectMultiple, - onSelectRow, - onFocus, - onLongPressRow, - shouldSyncFocus, - onCheckboxPress, - onDEWModalOpen, -}: ExpenseReportListItemProps) { - const reportItem = item as unknown as ExpenseReportListItemType; - const styles = useThemeStyles(); - const theme = useTheme(); - - const {isLargeScreenWidth} = useResponsiveLayout(); - const {currentSearchHash, currentSearchKey} = useSearchContext(); - const [lastPaymentMethod] = useOnyx(ONYXKEYS.NVP_LAST_PAYMENT_METHOD, {canBeMissing: true}); - const [snapshot] = useOnyx(`${ONYXKEYS.COLLECTION.SNAPSHOT}${currentSearchHash}`, {canBeMissing: true}); - - const snapshotReport = useMemo(() => { - // eslint-disable-next-line @typescript-eslint/no-deprecated - return (snapshot?.data?.[`${ONYXKEYS.COLLECTION.REPORT}${reportItem.reportID}`] ?? {}) as SearchReport; - }, [snapshot, reportItem.reportID]); - - const snapshotPolicy = useMemo(() => { - return (snapshot?.data?.[`${ONYXKEYS.COLLECTION.POLICY}${reportItem.policyID}`] ?? {}) as Policy; - }, [snapshot, reportItem.policyID]); - - const handleOnButtonPress = useCallback(() => { - handleActionButtonPress( - currentSearchHash, - reportItem, - () => onSelectRow(reportItem as unknown as TItem), - snapshotReport, - snapshotPolicy, - lastPaymentMethod, - currentSearchKey, - onDEWModalOpen, - ); - }, [currentSearchHash, reportItem, onSelectRow, snapshotReport, snapshotPolicy, lastPaymentMethod, currentSearchKey, onDEWModalOpen]); - - const listItemPressableStyle = [ - styles.selectionListPressableItemWrapper, - styles.pv3, - styles.ph3, - // Removing background style because they are added to the parent OpacityView via animatedHighlightStyle - styles.bgTransparent, - item.isSelected && styles.activeComponentBG, - styles.mh0, - ]; - - const listItemWrapperStyle = [ - styles.flex1, - styles.userSelectNone, - isLargeScreenWidth ? {...styles.flexRow, ...styles.justifyContentBetween, ...styles.alignItemsCenter} : {...styles.flexColumn, ...styles.alignItemsStretch}, - ]; - - const animatedHighlightStyle = useAnimatedHighlightStyle({ - borderRadius: variables.componentBorderRadius, - shouldHighlight: item?.shouldAnimateInHighlight ?? false, - highlightColor: theme.messageHighlightBG, - backgroundColor: theme.highlightBG, - }); - - return ( - - {(hovered) => ( - onCheckboxPress?.(reportItem as unknown as TItem)} - onButtonPress={handleOnButtonPress} - avatarBorderColor={theme.highlightBG} - isSelectAllChecked={!!reportItem.isSelected} - isIndeterminate={false} - isDisabled={!!isDisabled} - isHovered={hovered} - isFocused={isFocused} - /> - )} - - ); -} - -ExpenseReportListItem.displayName = 'ExpenseReportListItem'; - -export default ExpenseReportListItem; diff --git a/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx b/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx deleted file mode 100644 index 016ef94c936e..000000000000 --- a/src/components/SelectionListWithSections/Search/ExpenseReportListItemRow.tsx +++ /dev/null @@ -1,208 +0,0 @@ -import React, {useMemo} from 'react'; -import {View} from 'react-native'; -import type {ColorValue, StyleProp, ViewStyle} from 'react-native'; -import Checkbox from '@components/Checkbox'; -import ReportActionAvatars from '@components/ReportActionAvatars'; -import ReportSearchHeader from '@components/ReportSearchHeader'; -import type {ExpenseReportListItemType} from '@components/SelectionListWithSections/types'; -import useResponsiveLayout from '@hooks/useResponsiveLayout'; -import useStyleUtils from '@hooks/useStyleUtils'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; -import variables from '@styles/variables'; -import CONST from '@src/CONST'; -import ActionCell from './ActionCell'; -import DateCell from './DateCell'; -import StatusCell from './StatusCell'; -import TitleCell from './TitleCell'; -import TotalCell from './TotalCell'; -import UserInfoAndActionButtonRow from './UserInfoAndActionButtonRow'; -import UserInfoCell from './UserInfoCell'; - -type ExpenseReportListItemRowProps = { - item: ExpenseReportListItemType; - showTooltip: boolean; - canSelectMultiple?: boolean; - isActionLoading?: boolean; - onButtonPress?: () => void; - onCheckboxPress?: () => void; - containerStyle?: StyleProp; - avatarBorderColor?: ColorValue; - isSelectAllChecked?: boolean; - isIndeterminate?: boolean; - isDisabled?: boolean; - isHovered?: boolean; - isFocused?: boolean; -}; - -function ExpenseReportListItemRow({ - item, - onCheckboxPress = () => {}, - onButtonPress = () => {}, - isActionLoading, - containerStyle, - showTooltip, - canSelectMultiple, - avatarBorderColor, - isSelectAllChecked, - isIndeterminate, - isDisabled, - isHovered = false, - isFocused = false, -}: ExpenseReportListItemRowProps) { - const StyleUtils = useStyleUtils(); - const styles = useThemeStyles(); - const theme = useTheme(); - const {isLargeScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout(); - - const {total, currency} = useMemo(() => { - let reportTotal = item.total ?? 0; - - if (reportTotal) { - if (item.type === CONST.REPORT.TYPE.IOU) { - reportTotal = Math.abs(reportTotal ?? 0); - } else { - reportTotal *= item.type === CONST.REPORT.TYPE.EXPENSE || item.type === CONST.REPORT.TYPE.INVOICE ? -1 : 1; - } - } - - const reportCurrency = item.currency ?? CONST.CURRENCY.USD; - - return {total: reportTotal, currency: reportCurrency}; - }, [item.type, item.total, item.currency]); - - const thereIsFromAndTo = !!item?.from && !!item?.to; - const showUserInfo = (item.type === CONST.REPORT.TYPE.IOU && thereIsFromAndTo) || (item.type === CONST.REPORT.TYPE.EXPENSE && !!item?.from); - - // Calculate the correct border color for avatars based on hover and focus states - const finalAvatarBorderColor = isHovered && !isFocused ? theme.border : avatarBorderColor; - - if (!isLargeScreenWidth) { - return ( - - - - - {!!canSelectMultiple && ( - - )} - - - - - - - - - - ); - } - - return ( - - - {!!canSelectMultiple && ( - - )} - - - - - - - - - - - - - - {!!item.from && ( - - )} - - - {!!item.to && ( - - )} - - - - - - - - - - ); -} - -ExpenseReportListItemRow.displayName = 'ExpenseReportListItemRow'; - -export default ExpenseReportListItemRow; diff --git a/src/components/SelectionListWithSections/Search/StatusCell.tsx b/src/components/SelectionListWithSections/Search/StatusCell.tsx deleted file mode 100644 index 77bc786ab71f..000000000000 --- a/src/components/SelectionListWithSections/Search/StatusCell.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import React, {useMemo} from 'react'; -import {View} from 'react-native'; -import Text from '@components/Text'; -import useLocalize from '@hooks/useLocalize'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; -import {getReportStatusColorStyle, getReportStatusTranslation} from '@libs/ReportUtils'; - -type StatusCellProps = { - /** The stateNum of the report */ - stateNum?: number; - - /** The statusNum of the report */ - statusNum?: number; -}; - -function StatusCell({stateNum, statusNum}: StatusCellProps) { - const styles = useThemeStyles(); - const theme = useTheme(); - const {translate} = useLocalize(); - - const statusText = useMemo(() => getReportStatusTranslation({stateNum, statusNum, translate}), [stateNum, statusNum, translate]); - const reportStatusColorStyle = useMemo(() => getReportStatusColorStyle(theme, stateNum, statusNum), [theme, stateNum, statusNum]); - - if (!statusText || !reportStatusColorStyle) { - return null; - } - - return ( - - - {statusText} - - - ); -} - -StatusCell.displayName = 'StatusCell'; - -export default StatusCell; diff --git a/src/components/SelectionListWithSections/Search/TitleCell.tsx b/src/components/SelectionListWithSections/Search/TitleCell.tsx deleted file mode 100644 index 562a4ed7210e..000000000000 --- a/src/components/SelectionListWithSections/Search/TitleCell.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import React from 'react'; -import TextWithTooltip from '@components/TextWithTooltip'; -import useThemeStyles from '@hooks/useThemeStyles'; - -type TitleCellProps = { - text: string; - isLargeScreenWidth: boolean; -}; - -function TitleCell({text, isLargeScreenWidth}: TitleCellProps) { - const styles = useThemeStyles(); - - return ( - - ); -} - -export default TitleCell; diff --git a/src/components/SelectionListWithSections/Search/TransactionGroupListExpanded.tsx b/src/components/SelectionListWithSections/Search/TransactionGroupListExpanded.tsx index 25f188501846..d78ab2c80762 100644 --- a/src/components/SelectionListWithSections/Search/TransactionGroupListExpanded.tsx +++ b/src/components/SelectionListWithSections/Search/TransactionGroupListExpanded.tsx @@ -74,7 +74,7 @@ function TransactionGroupListExpanded({ if (!transactionsSnapshot?.data) { return []; } - const columnsToShow = getColumnsToShow(accountID, transactionsSnapshot?.data, false, transactionsSnapshot?.search.type); + const columnsToShow = getColumnsToShow(accountID, transactionsSnapshot?.data, false, transactionsSnapshot?.search.type === CONST.SEARCH.DATA_TYPES.TASK); return (Object.keys(columnsToShow) as SearchColumnType[]).filter((col) => columnsToShow[col]); }, [accountID, columns, isExpenseReportType, transactionsSnapshot?.data, transactionsSnapshot?.search.type]); diff --git a/src/components/SelectionListWithSections/SearchTableHeader.tsx b/src/components/SelectionListWithSections/SearchTableHeader.tsx index 9477cfcad84f..9d82e407086a 100644 --- a/src/components/SelectionListWithSections/SearchTableHeader.tsx +++ b/src/components/SelectionListWithSections/SearchTableHeader.tsx @@ -1,20 +1,17 @@ import React, {useCallback} from 'react'; import type {ValueOf} from 'type-fest'; -import * as Expensicons from '@components/Icon/Expensicons'; import type {SearchColumnType, SearchGroupBy, SortOrder} from '@components/Search/types'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import type {SearchDataTypes} from '@src/types/onyx/SearchResults'; -import type IconAsset from '@src/types/utils/IconAsset'; import SortableTableHeader from './SortableTableHeader'; import type {SortableColumnName} from './types'; type SearchColumnConfig = { columnName: SearchColumnType; - translationKey: TranslationPaths | undefined; - icon?: IconAsset; + translationKey: TranslationPaths; isColumnSortable?: boolean; canBeMissing?: boolean; }; @@ -129,44 +126,6 @@ const taskHeaders: SearchColumnConfig[] = [ }, ]; -const expenseReportHeaders: SearchColumnConfig[] = [ - { - columnName: CONST.SEARCH.TABLE_COLUMNS.AVATAR, - translationKey: undefined, - icon: Expensicons.Profile, - isColumnSortable: false, - }, - { - columnName: CONST.SEARCH.TABLE_COLUMNS.DATE, - translationKey: 'common.date', - }, - { - columnName: CONST.SEARCH.TABLE_COLUMNS.STATUS, - translationKey: 'common.status', - }, - { - columnName: CONST.SEARCH.TABLE_COLUMNS.TITLE, - translationKey: 'common.reportName', - }, - { - columnName: CONST.SEARCH.TABLE_COLUMNS.FROM, - translationKey: 'common.from', - }, - { - columnName: CONST.SEARCH.TABLE_COLUMNS.TO, - translationKey: 'common.to', - }, - { - columnName: CONST.SEARCH.TABLE_COLUMNS.TOTAL, - translationKey: 'common.total', - }, - { - columnName: CONST.SEARCH.TABLE_COLUMNS.ACTION, - translationKey: 'common.action', - isColumnSortable: false, - }, -]; - function getSearchColumns(type: ValueOf, groupBy?: SearchGroupBy) { switch (type) { case CONST.SEARCH.DATA_TYPES.EXPENSE: @@ -177,8 +136,6 @@ function getSearchColumns(type: ValueOf, groupBy return getExpenseHeaders(groupBy); case CONST.SEARCH.DATA_TYPES.TASK: return taskHeaders; - case CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT: - return expenseReportHeaders; case CONST.SEARCH.DATA_TYPES.CHAT: default: return null; diff --git a/src/components/SelectionListWithSections/SortableHeaderText.tsx b/src/components/SelectionListWithSections/SortableHeaderText.tsx index 6997d5b5dd85..47a894d79f53 100644 --- a/src/components/SelectionListWithSections/SortableHeaderText.tsx +++ b/src/components/SelectionListWithSections/SortableHeaderText.tsx @@ -9,11 +9,9 @@ import Text from '@components/Text'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import CONST from '@src/CONST'; -import type IconAsset from '@src/types/utils/IconAsset'; type SearchTableHeaderColumnProps = { text: string; - icon?: IconAsset; isActive: boolean; sortOrder: SortOrder; isSortable?: boolean; @@ -22,7 +20,7 @@ type SearchTableHeaderColumnProps = { onPress: (order: SortOrder) => void; }; -export default function SortableHeaderText({text, icon, sortOrder, isActive, textStyle, containerStyle, isSortable = true, onPress}: SearchTableHeaderColumnProps) { +export default function SortableHeaderText({text, sortOrder, isActive, textStyle, containerStyle, isSortable = true, onPress}: SearchTableHeaderColumnProps) { const styles = useThemeStyles(); const theme = useTheme(); @@ -30,28 +28,18 @@ export default function SortableHeaderText({text, icon, sortOrder, isActive, tex return ( - {!!icon && ( - - )} - {!!text && ( - - {text} - - )} + + {text} + ); } - const sortArrowIcon = sortOrder === CONST.SEARCH.SORT_ORDER.ASC ? Expensicons.ArrowUpLong : Expensicons.ArrowDownLong; + const icon = sortOrder === CONST.SEARCH.SORT_ORDER.ASC ? Expensicons.ArrowUpLong : Expensicons.ArrowDownLong; const displayIcon = isActive; const activeColumnStyle = isSortable && isActive && styles.searchTableHeaderActive; @@ -67,25 +55,15 @@ export default function SortableHeaderText({text, icon, sortOrder, isActive, tex disabled={!isSortable} > - {!!icon && ( - - )} - {!!text && ( - - {text} - - )} + + {text} + {displayIcon && ( - {columns.map(({columnName, translationKey, icon, isColumnSortable}) => { + {columns.map(({columnName, translationKey, isColumnSortable}) => { if (!shouldShowColumn(columnName)) { return null; } @@ -66,7 +64,6 @@ function SortableTableHeader({ = ListItemProps & { personalDetails: OnyxEntry; }; -type ExpenseReportListItemProps = ListItemProps & { - /** Whether the item's action is loading */ - isLoading?: boolean; - - /** Callback to fire when DEW modal should be opened */ - onDEWModalOpen?: () => void; -}; - type TransactionGroupListItemProps = ListItemProps & { groupBy?: SearchGroupBy; searchType?: SearchDataTypes; @@ -1038,7 +1013,7 @@ type SectionListDataType = ExtendedSectionListData = { copyToClipboard: 'In die Zwischenablage kopieren', thisIsTakingLongerThanExpected: 'Das dauert länger als erwartet...', domains: 'Domänen', - reportName: 'Berichtsname', }, supportalNoAccess: { title: 'Nicht so schnell', diff --git a/src/languages/en.ts b/src/languages/en.ts index 5dfa0159556c..42e84614e459 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -579,7 +579,6 @@ const translations = { businessName: 'Business name', clear: 'Clear', type: 'Type', - reportName: 'Report name', action: 'Action', expenses: 'Expenses', totalSpend: 'Total spend', diff --git a/src/languages/es.ts b/src/languages/es.ts index 878330f910c0..540fccfcc04c 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -265,7 +265,6 @@ const translations: TranslationDeepObject = { businessName: 'Nombre de la empresa', clear: 'Borrar', type: 'Tipo', - reportName: 'Nombre del informe', action: 'Acción', expenses: 'Gastos', totalSpend: 'Gasto total', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 2364019542a5..f3505069dee9 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -694,7 +694,6 @@ const translations: TranslationDeepObject = { copyToClipboard: 'Copier dans le presse-papiers', thisIsTakingLongerThanExpected: 'Cela prend plus de temps que prévu...', domains: 'Domaines', - reportName: 'Nom du rapport', }, supportalNoAccess: { title: 'Pas si vite', diff --git a/src/languages/it.ts b/src/languages/it.ts index 405d1d23abb2..d4a7ef8a4ccd 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -694,7 +694,6 @@ const translations: TranslationDeepObject = { copyToClipboard: 'Copia negli appunti', thisIsTakingLongerThanExpected: 'Sta richiedendo più tempo del previsto...', domains: 'Domini', - reportName: 'Nome del report', }, supportalNoAccess: { title: 'Non così in fretta', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index a94ff0bc5826..cc976477b0aa 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -694,7 +694,6 @@ const translations: TranslationDeepObject = { copyToClipboard: 'クリップボードにコピー', thisIsTakingLongerThanExpected: '予想より時間がかかっています...', domains: 'ドメイン', - reportName: 'レポート名', }, supportalNoAccess: { title: 'ちょっと待ってください', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 9c253e1ac2c7..ea9117b8a336 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -693,7 +693,6 @@ const translations: TranslationDeepObject = { copyToClipboard: 'Kopiëren naar klembord', thisIsTakingLongerThanExpected: 'Dit duurt langer dan verwacht...', domains: 'Domeinen', - reportName: 'Rapportnaam', }, supportalNoAccess: { title: 'Niet zo snel', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index cf828874a4b0..bf3b76d10c5e 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -694,7 +694,6 @@ const translations: TranslationDeepObject = { copyToClipboard: 'Skopiuj do schowka', thisIsTakingLongerThanExpected: 'To trwa dłużej niż oczekiwano...', domains: 'Domeny', - reportName: 'Nazwa raportu', }, supportalNoAccess: { title: 'Nie tak szybko', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index d02230b3ac25..8f262ba0e939 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -693,7 +693,6 @@ const translations: TranslationDeepObject = { copyToClipboard: 'Copiar para a área de transferência', thisIsTakingLongerThanExpected: 'Isso está demorando mais do que o esperado...', domains: 'Domínios', - reportName: 'Nome do relatório', }, supportalNoAccess: { title: 'Não tão rápido', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index c403a70ac166..76dfdb3880c1 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -688,7 +688,6 @@ const translations: TranslationDeepObject = { copyToClipboard: '复制到剪贴板', thisIsTakingLongerThanExpected: '这花的时间比预期更长...', domains: '域名', - reportName: '报告名称', }, supportalNoAccess: { title: '慢一点', diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index dceb2b0ab1f2..367d6188c624 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -20,12 +20,10 @@ import type { SortOrder, } from '@components/Search/types'; import ChatListItem from '@components/SelectionListWithSections/ChatListItem'; -import ExpenseReportListItem from '@components/SelectionListWithSections/Search/ExpenseReportListItem'; import TaskListItem from '@components/SelectionListWithSections/Search/TaskListItem'; import TransactionGroupListItem from '@components/SelectionListWithSections/Search/TransactionGroupListItem'; import TransactionListItem from '@components/SelectionListWithSections/Search/TransactionListItem'; import type { - ExpenseReportListItemType, ListItem, ReportActionListItemType, SearchListItem, @@ -92,7 +90,6 @@ import { getPersonalDetailsForAccountID, getReportName, getReportOrDraftReport, - getReportStatusTranslation, getSearchReportName, hasAnyViolations, hasInvoiceReports, @@ -126,14 +123,7 @@ import { import shouldShowTransactionYear from './TransactionUtils/shouldShowTransactionYear'; import ViolationsUtils from './Violations/ViolationsUtils'; -type ColumnSortMapping = Partial>; -type ColumnVisibility = Partial>; - -type TransactionSorting = ColumnSortMapping; -type TaskSorting = ColumnSortMapping; -type ExpenseReportSorting = ColumnSortMapping; - -const transactionColumnNamesToSortingProperty: TransactionSorting = { +const transactionColumnNamesToSortingProperty = { [CONST.SEARCH.TABLE_COLUMNS.TO]: 'formattedTo' as const, [CONST.SEARCH.TABLE_COLUMNS.FROM]: 'formattedFrom' as const, [CONST.SEARCH.TABLE_COLUMNS.DATE]: 'date' as const, @@ -146,9 +136,10 @@ const transactionColumnNamesToSortingProperty: TransactionSorting = { [CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION]: 'comment' as const, [CONST.SEARCH.TABLE_COLUMNS.TAX_AMOUNT]: null, [CONST.SEARCH.TABLE_COLUMNS.RECEIPT]: null, + [CONST.SEARCH.TABLE_COLUMNS.IN]: 'parentReportID' as const, }; -const taskColumnNamesToSortingProperty: TaskSorting = { +const taskColumnNamesToSortingProperty = { [CONST.SEARCH.TABLE_COLUMNS.DATE]: 'created' as const, [CONST.SEARCH.TABLE_COLUMNS.DESCRIPTION]: 'description' as const, [CONST.SEARCH.TABLE_COLUMNS.TITLE]: 'reportName' as const, @@ -157,17 +148,6 @@ const taskColumnNamesToSortingProperty: TaskSorting = { [CONST.SEARCH.TABLE_COLUMNS.IN]: 'parentReportID' as const, }; -const expenseReportColumnNamesToSortingProperty: ExpenseReportSorting = { - [CONST.SEARCH.TABLE_COLUMNS.AVATAR]: null, - [CONST.SEARCH.TABLE_COLUMNS.DATE]: 'created' as const, - [CONST.SEARCH.TABLE_COLUMNS.STATUS]: 'formattedStatus' as const, - [CONST.SEARCH.TABLE_COLUMNS.TITLE]: 'reportName' as const, - [CONST.SEARCH.TABLE_COLUMNS.FROM]: 'formattedFrom' as const, - [CONST.SEARCH.TABLE_COLUMNS.TO]: 'formattedTo' as const, - [CONST.SEARCH.TABLE_COLUMNS.TOTAL]: 'total' as const, - [CONST.SEARCH.TABLE_COLUMNS.ACTION]: 'action' as const, -}; - const expenseStatusActionMapping = { // eslint-disable-next-line @typescript-eslint/no-deprecated [CONST.SEARCH.STATUS.EXPENSE.DRAFTS]: (expenseReport?: SearchReport) => @@ -828,10 +808,8 @@ function getWideAmountIndicators(data: TransactionListItemType[] | TransactionGr /** * Checks if the date of transactions or reports indicate the need to display the year because they are from a past year. - * @param data - The search results data (array or object) - * @param checkOnlyReports - When true and data is an object, only check report dates (skip transactions and report actions) */ -function shouldShowYear(data: TransactionListItemType[] | TransactionGroupListItemType[] | TaskListItemType[] | OnyxTypes.SearchResults['data'], checkOnlyReports = false) { +function shouldShowYear(data: TransactionListItemType[] | TransactionGroupListItemType[] | TaskListItemType[] | OnyxTypes.SearchResults['data']) { const currentYear = new Date().getFullYear(); if (Array.isArray(data)) { @@ -855,12 +833,12 @@ function shouldShowYear(data: TransactionListItemType[] | TransactionGroupListIt } for (const key in data) { - if (!checkOnlyReports && isTransactionEntry(key)) { + if (isTransactionEntry(key)) { const item = data[key]; if (shouldShowTransactionYear(item)) { return true; } - } else if (!checkOnlyReports && isReportActionEntry(key)) { + } else if (isReportActionEntry(key)) { const item = data[key]; for (const action of Object.values(item)) { const date = action.created; @@ -1465,7 +1443,6 @@ function getReportSections( ); const orderedKeys: string[] = [...reportKeys, ...transactionKeys]; - const doesDataContainAPastYearReport = shouldShowYear(data, true); for (const key of orderedKeys) { if (isReportEntry(key) && (data[key].type === CONST.REPORT.TYPE.IOU || data[key].type === CONST.REPORT.TYPE.EXPENSE || data[key].type === CONST.REPORT.TYPE.INVOICE)) { @@ -1494,30 +1471,16 @@ function getReportSections( const reportPendingAction = reportItem?.pendingAction ?? reportItem?.pendingFields?.preview; const shouldShowBlankTo = !reportItem || isOpenExpenseReport(reportItem); const allActions = getActions(data, allViolations, key, currentSearch, currentAccountID, currentUserEmail, actions); - - const fromDetails = data.personalDetailsList[reportItem.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID]; - - const toDetails = !shouldShowBlankTo && reportItem.managerID ? data.personalDetailsList?.[reportItem.managerID] : emptyPersonalDetails; - const formattedFrom = fromDetails === emptyPersonalDetails ? '' : formatPhoneNumber(getDisplayNameOrDefault(fromDetails)); - const formattedTo = shouldShowBlankTo ? '' : formatPhoneNumber(getDisplayNameOrDefault(toDetails)); - - // eslint-disable-next-line @typescript-eslint/no-deprecated - const formattedStatus = getReportStatusTranslation({stateNum: reportItem.stateNum, statusNum: reportItem.statusNum, translate: translateLocal}); - reportIDToTransactions[reportKey] = { ...reportItem, action: allActions.at(0) ?? CONST.SEARCH.ACTION_TYPES.VIEW, allActions, keyForList: String(reportItem.reportID), groupedBy: CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT, - from: fromDetails, - to: toDetails, - formattedFrom, - formattedTo, - formattedStatus, + from: transactions.length > 0 ? data.personalDetailsList[data?.[reportKey as ReportKey]?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID] : emptyPersonalDetails, + to: !shouldShowBlankTo && reportItem.managerID ? data.personalDetailsList?.[reportItem.managerID] : emptyPersonalDetails, transactions, ...(reportPendingAction ? {pendingAction: reportPendingAction} : {}), - shouldShowYear: doesDataContainAPastYearReport, }; if (isIOUReport) { @@ -1695,10 +1658,7 @@ function getListItem(type: SearchDataTypes, status: SearchStatus, groupBy?: Sear if (type === CONST.SEARCH.DATA_TYPES.TASK) { return TaskListItem; } - if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) { - return ExpenseReportListItem; - } - if (groupBy) { + if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT || groupBy) { return TransactionGroupListItem; } return TransactionListItem; @@ -1765,7 +1725,7 @@ function getSortedSections( return getSortedTaskData(data as TaskListItemType[], localeCompare, sortBy, sortOrder); } if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) { - return getSortedReportData(data as TransactionReportGroupListItemType[], localeCompare, sortBy, sortOrder); + return getSortedReportData(data as TransactionReportGroupListItemType[], localeCompare); } if (groupBy) { @@ -1817,7 +1777,7 @@ function getSortedTransactionData(data: TransactionListItemType[], localeCompare return data; } - const sortingProperty = transactionColumnNamesToSortingProperty[sortBy]; + const sortingProperty = transactionColumnNamesToSortingProperty[sortBy as keyof typeof transactionColumnNamesToSortingProperty]; if (!sortingProperty) { return data; @@ -1836,15 +1796,15 @@ function getSortedTaskData(data: TaskListItemType[], localeCompare: LocaleContex return data; } - const sortingProperty = taskColumnNamesToSortingProperty[sortBy]; + const sortingProperty = taskColumnNamesToSortingProperty[sortBy as keyof typeof taskColumnNamesToSortingProperty]; if (!sortingProperty) { return data; } return data.sort((a, b) => { - const aValue = a[sortingProperty]; - const bValue = b[sortingProperty]; + const aValue = a[sortingProperty as keyof TaskListItemType]; + const bValue = b[sortingProperty as keyof TaskListItemType]; return compareValues(aValue, bValue, sortOrder, sortingProperty, localeCompare); }); @@ -1854,39 +1814,17 @@ function getSortedTaskData(data: TaskListItemType[], localeCompare: LocaleContex * @private * Sorts report sections based on a specified column and sort order. */ -function getSortedReportData(data: TransactionReportGroupListItemType[], localeCompare: LocaleContextProps['localeCompare'], sortBy?: SearchColumnType, sortOrder?: SortOrder) { +function getSortedReportData(data: TransactionReportGroupListItemType[], localeCompare: LocaleContextProps['localeCompare']) { for (const report of data) { report.transactions = getSortedTransactionData(report.transactions, localeCompare, CONST.SEARCH.TABLE_COLUMNS.DATE, CONST.SEARCH.SORT_ORDER.DESC); } - if (!sortBy || !sortOrder) { - return data.sort((a, b) => { - if (!a.created || !b.created) { - return 0; - } - - return localeCompare(b.created.toLowerCase(), a.created.toLowerCase()); - }); - } - - const sortingProperty = expenseReportColumnNamesToSortingProperty[sortBy]; - - if (!sortingProperty) { - return data; - } - return data.sort((a, b) => { - let aValue = a[sortingProperty]; - let bValue = b[sortingProperty]; - - // When sorting by total, apply the backend logic: - // IOU reports have positive amounts, expense reports have negative amounts - if (sortingProperty === 'total' && typeof aValue === 'number' && typeof bValue === 'number') { - aValue = a.type === CONST.REPORT.TYPE.IOU ? aValue : -(aValue as number); - bValue = b.type === CONST.REPORT.TYPE.IOU ? bValue : -(bValue as number); + if (!a.created || !b.created) { + return 0; } - return compareValues(aValue, bValue, sortOrder, sortingProperty, localeCompare); + return localeCompare(b.created.toLowerCase(), a.created.toLowerCase()); }); } @@ -2394,22 +2332,9 @@ function getColumnsToShow( currentAccountID: number | undefined, data: OnyxTypes.SearchResults['data'] | OnyxTypes.Transaction[], isExpenseReportView = false, - type?: SearchDataTypes, -): ColumnVisibility { - if (type === CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT) { - return { - [CONST.SEARCH.TABLE_COLUMNS.AVATAR]: true, - [CONST.SEARCH.TABLE_COLUMNS.DATE]: true, - [CONST.SEARCH.TABLE_COLUMNS.STATUS]: true, - [CONST.SEARCH.TABLE_COLUMNS.TITLE]: true, - [CONST.SEARCH.TABLE_COLUMNS.FROM]: true, - [CONST.SEARCH.TABLE_COLUMNS.TO]: true, - [CONST.SEARCH.TABLE_COLUMNS.TOTAL]: true, - [CONST.SEARCH.TABLE_COLUMNS.ACTION]: true, - }; - } - - if (type === CONST.SEARCH.DATA_TYPES.TASK) { + isTaskView = false, +): Record { + if (isTaskView) { return { [CONST.SEARCH.TABLE_COLUMNS.DATE]: true, [CONST.SEARCH.TABLE_COLUMNS.TITLE]: true, @@ -2432,7 +2357,7 @@ function getColumnsToShow( }; } - const columns: ColumnVisibility = isExpenseReportView + const columns: Record = isExpenseReportView ? { [CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT]: true, [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE]: true, diff --git a/src/styles/utils/index.ts b/src/styles/utils/index.ts index 437f5e17e121..31f4e4341dd7 100644 --- a/src/styles/utils/index.ts +++ b/src/styles/utils/index.ts @@ -1725,12 +1725,6 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ case CONST.SEARCH.TABLE_COLUMNS.RECEIPT: columnWidth = {...getWidthStyle(variables.w36), ...styles.alignItemsCenter}; break; - case CONST.SEARCH.TABLE_COLUMNS.AVATAR: - columnWidth = {...getWidthStyle(variables.w40), ...styles.alignItemsCenter}; - break; - case CONST.SEARCH.TABLE_COLUMNS.STATUS: - columnWidth = {...getWidthStyle(variables.w80), ...styles.alignItemsCenter}; - break; case CONST.SEARCH.TABLE_COLUMNS.DATE: if (isDateColumnFullWidth) { columnWidth = styles.flex1; @@ -1755,7 +1749,6 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({ columnWidth = {...getWidthStyle(isTaxAmountColumnWide ? variables.w130 : variables.w96), ...styles.alignItemsEnd}; break; case CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT: - case CONST.SEARCH.TABLE_COLUMNS.TOTAL: columnWidth = {...getWidthStyle(isAmountColumnWide ? variables.w130 : variables.w96), ...styles.alignItemsEnd}; break; case CONST.SEARCH.TABLE_COLUMNS.TYPE: diff --git a/src/styles/variables.ts b/src/styles/variables.ts index c80e8f838c34..ad067ed20605 100644 --- a/src/styles/variables.ts +++ b/src/styles/variables.ts @@ -380,7 +380,4 @@ export default { uberEmployeeInviteButtonWidth: 62, uberEmptyListIconWidth: 190, uberEmptyListIconHeight: 136, - - // Report search header max width - reportSearchHeaderMaxWidth: 700, } as const; diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index af6814b9e35b..fbb8ec8d9cd9 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -1,7 +1,6 @@ import type {OnyxCollection} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import ChatListItem from '@components/SelectionListWithSections/ChatListItem'; -import ExpenseReportListItem from '@components/SelectionListWithSections/Search/ExpenseReportListItem'; import TransactionGroupListItem from '@components/SelectionListWithSections/Search/TransactionGroupListItem'; import TransactionListItem from '@components/SelectionListWithSections/Search/TransactionListItem'; import type { @@ -1042,9 +1041,6 @@ const transactionReportGroupListItems = [ chatReportID: '1706144653204915', created: '2024-12-21 13:05:20', currency: 'USD', - formattedFrom: 'Admin', - formattedStatus: 'Draft', - formattedTo: '', from: { accountID: 18439984, avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', @@ -1060,7 +1056,6 @@ const transactionReportGroupListItems = [ policyID: 'A1B2C3', reportID: '123456789', reportName: 'Expense Report #123', - shouldShowYear: true, stateNum: 0, statusNum: 0, to: { @@ -1147,9 +1142,6 @@ const transactionReportGroupListItems = [ chatReportID: '1706144653204915', created: '2024-12-21 13:05:20', currency: 'USD', - formattedFrom: 'Admin', - formattedStatus: 'Outstanding', - formattedTo: 'Admin', from: { accountID: 18439984, avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', @@ -1165,7 +1157,6 @@ const transactionReportGroupListItems = [ policyID: 'A1B2C3', reportID: '11111', reportName: 'Expense Report #123', - shouldShowYear: true, stateNum: 1, statusNum: 1, to: { @@ -1256,9 +1247,6 @@ const transactionReportGroupListItems = [ chatType: undefined, created: '2025-03-05 16:34:27', currency: 'VND', - formattedFrom: 'Admin', - formattedStatus: 'Outstanding', - formattedTo: 'Approver', isOneTransactionReport: false, isOwnPolicyExpenseChat: false, isWaitingOnBankAccount: false, @@ -1270,7 +1258,6 @@ const transactionReportGroupListItems = [ private_isArchived: '', reportID: '99999', reportName: 'Approver owes ₫44.00', - shouldShowYear: true, stateNum: 1, statusNum: 1, total: 4400, @@ -1301,14 +1288,11 @@ const transactionReportGroupListItems = [ chatReportID: '1706144653204915', created: '2024-12-21 13:05:20', currency: 'USD', - formattedFrom: 'Admin', - formattedStatus: 'Draft', - formattedTo: '', from: { - accountID: 18439984, - avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/avatar_3.png', - displayName: 'Admin', - login: 'admin@policy.com', + accountID: CONST.REPORT.OWNER_ACCOUNT_ID_FAKE, + avatar: '', + displayName: undefined, + login: undefined, }, isOneTransactionReport: true, isWaitingOnBankAccount: false, @@ -1319,7 +1303,6 @@ const transactionReportGroupListItems = [ policyID: 'A1B2C3', reportID: reportID5, reportName: 'Expense Report #123', - shouldShowYear: true, stateNum: 0, statusNum: 0, to: { @@ -1757,8 +1740,8 @@ describe('SearchUIUtils', () => { expect(SearchUIUtils.getListItem(CONST.SEARCH.DATA_TYPES.EXPENSE, CONST.SEARCH.STATUS.EXPENSE.ALL, undefined)).toStrictEqual(TransactionListItem); }); - it('should return ExpenseReportListItem when type is EXPENSE-REPORT', () => { - expect(SearchUIUtils.getListItem(CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT, CONST.SEARCH.STATUS.EXPENSE.ALL)).toStrictEqual(ExpenseReportListItem); + it('should return TransactionGroupListItem when type is EXPENSE-REPORT', () => { + expect(SearchUIUtils.getListItem(CONST.SEARCH.DATA_TYPES.EXPENSE_REPORT, CONST.SEARCH.STATUS.EXPENSE.ALL)).toStrictEqual(TransactionGroupListItem); }); it('should return TransactionListItem when type is TRIP', () => { diff --git a/tests/unit/Search/handleActionButtonPressTest.ts b/tests/unit/Search/handleActionButtonPressTest.ts index f576be3c46c8..e595bb796f56 100644 --- a/tests/unit/Search/handleActionButtonPressTest.ts +++ b/tests/unit/Search/handleActionButtonPressTest.ts @@ -63,7 +63,6 @@ const mockReportItemWithHold = { phoneNumber: '', validated: false, }, - shouldShowYear: false, transactions: [ { report: { diff --git a/tests/unit/TransactionGroupListItemTest.tsx b/tests/unit/TransactionGroupListItemTest.tsx index 2844ac45fd2a..79abf4cd5cbe 100644 --- a/tests/unit/TransactionGroupListItemTest.tsx +++ b/tests/unit/TransactionGroupListItemTest.tsx @@ -120,7 +120,6 @@ const mockReport: TransactionReportGroupListItemType = { avatar: 'https://d2k5nsl2zxldvw.cloudfront.net/images/avatars/default-avatar_15.png', displayName: 'Main Applause QA', }, - shouldShowYear: false, action: 'view', transactions: [], groupedBy: 'expense-report',