From 0910f09786523b652283260e3939aa26f511e863 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Wed, 28 May 2025 11:48:01 +0200 Subject: [PATCH 01/21] replace TransactionListItemRow with TransactionItemRow --- .../Search/TransactionListItem.tsx | 72 +++++++++++++++---- .../Search/UserInfoAndActionButtonRow.tsx | 47 ++++++++++++ src/components/TransactionItemRow/index.tsx | 16 +++-- 3 files changed, 115 insertions(+), 20 deletions(-) create mode 100644 src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx diff --git a/src/components/SelectionList/Search/TransactionListItem.tsx b/src/components/SelectionList/Search/TransactionListItem.tsx index 2582f1fb23cc..3381ebfe21ad 100644 --- a/src/components/SelectionList/Search/TransactionListItem.tsx +++ b/src/components/SelectionList/Search/TransactionListItem.tsx @@ -1,14 +1,18 @@ -import React from 'react'; +import React, {useMemo} from 'react'; +import type {ValueOf} from 'type-fest'; import {useSearchContext} from '@components/Search/SearchContext'; import BaseListItem from '@components/SelectionList/BaseListItem'; import type {ListItem, TransactionListItemProps, TransactionListItemType} from '@components/SelectionList/types'; +import TransactionItemRow from '@components/TransactionItemRow'; import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import {handleActionButtonPress} from '@libs/actions/Search'; +import shouldShowTransactionYear from '@libs/TransactionUtils/shouldShowTransactionYear'; import variables from '@styles/variables'; -import TransactionListItemRow from './TransactionListItemRow'; +import CONST from '@src/CONST'; +import UserInfoAndActionButtonRow from './UserInfoAndActionButtonRow'; function TransactionListItem({ item, @@ -53,6 +57,27 @@ function TransactionListItem({ backgroundColor: theme.highlightBG, }); + const dateColumnSize = useMemo(() => { + const shouldShowYearForSomeTransaction = shouldShowTransactionYear(transactionItem); + return shouldShowYearForSomeTransaction ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL; + }, [transactionItem]); + + const {COLUMNS} = CONST.REPORT.TRANSACTION_LIST; + + const columns = [ + COLUMNS.RECEIPT, + COLUMNS.TYPE, + COLUMNS.DATE, + COLUMNS.MERCHANT, + COLUMNS.FROM, + COLUMNS.TO, + ...(transactionItem?.shouldShowCategory ? [COLUMNS.CATEGORY] : []), + ...(transactionItem?.shouldShowTag ? [COLUMNS.TAG] : []), + ...(transactionItem?.shouldShowTax ? [COLUMNS.TAX] : []), + COLUMNS.TOTAL_AMOUNT, + COLUMNS.ACTION, + ] as Array>; + return ( ({ hoverStyle={item.isSelected && styles.activeComponentBG} pressableWrapperStyle={[styles.mh5, animatedHighlightStyle]} > - { - handleActionButtonPress(currentSearchHash, transactionItem, () => onSelectRow(item)); - }} - onCheckboxPress={() => onCheckboxPress?.(item)} - isDisabled={!!isDisabled} - canSelectMultiple={!!canSelectMultiple} - isButtonSelected={item.isSelected} - shouldShowTransactionCheckbox={false} - isLoading={isLoading ?? transactionItem.isActionLoading} - /> + {(hovered) => ( + <> + {!isLargeScreenWidth && ( + { + handleActionButtonPress(currentSearchHash, transactionItem, () => onSelectRow(item)); + }} + /> + )} + { + handleActionButtonPress(currentSearchHash, transactionItem, () => onSelectRow(item)); + }} + onCheckboxPress={() => onCheckboxPress?.(item)} + shouldUseNarrowLayout={!isLargeScreenWidth} + columns={columns} + isParentHovered={hovered} + isActionLoading={isLoading ?? transactionItem.isActionLoading} + isSelected={!!transactionItem.isSelected} + dateColumnSize={dateColumnSize} + shouldShowCheckbox={!!canSelectMultiple} + columnWrapperStyles={[styles.ph3, styles.pv1half]} + isChildListItem={false} + usedInExpenses + /> + + )} ); } diff --git a/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx b/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx new file mode 100644 index 000000000000..dfdda7c452d7 --- /dev/null +++ b/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx @@ -0,0 +1,47 @@ +import React from 'react'; +import {View} from 'react-native'; +import type {ReportListItemType, TransactionListItemType} from '@components/SelectionList/types'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import ActionCell from './ActionCell'; +import UserInfoCellsWithArrow from './UserInfoCellsWithArrow'; + +function UserInfoAndActionButtonRow({item, handleActionButtonPress}: {item: ReportListItemType | TransactionListItemType; handleActionButtonPress: () => void}) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const hasFromSender = !!item?.from && !!item?.from?.accountID && !!item?.from?.displayName; + const hasToRecipent = !!item?.to && !!item?.to?.accountID && !!item?.to?.displayName; + const showArrowComponent = hasFromSender || hasToRecipent; + const shouldShowToRecipient = hasFromSender && hasToRecipent && item?.from?.accountID !== item?.to?.accountID; + + return ( + + + {showArrowComponent && ( + + )} + + + + + + ); +} + +export default UserInfoAndActionButtonRow; diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index bd1b99be571f..eee21c64d542 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -63,6 +63,9 @@ function TransactionItemRow({ isParentHovered, columnWrapperStyles, scrollToNewTransaction, + isChildListItem = true, + isActionLoading, + usedInExpenses, }: { transactionItem: TransactionWithOptionalSearchFields; shouldUseNarrowLayout: boolean; @@ -76,6 +79,9 @@ function TransactionItemRow({ isParentHovered?: boolean; columnWrapperStyles?: ViewStyle[]; scrollToNewTransaction?: ((offset: number) => void) | undefined; + isChildListItem?: boolean; + isActionLoading?: boolean; + usedInExpenses?: boolean; }) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); @@ -170,10 +176,10 @@ function TransactionItemRow({ )} @@ -232,9 +238,9 @@ function TransactionItemRow({ ), }), - [StyleUtils, createdAt, isDateColumnWide, isSelected, onButtonPress, shouldShowTooltip, shouldUseNarrowLayout, transactionItem], + [StyleUtils, createdAt, isActionLoading, isChildListItem, isDateColumnWide, isSelected, onButtonPress, shouldShowTooltip, shouldUseNarrowLayout, transactionItem], ); - const safeColumnWrapperStyle = columnWrapperStyles ?? [styles.p3, styles.expenseWidgetRadius]; + const safeColumnWrapperStyle = !usedInExpenses ? columnWrapperStyles ?? [styles.p3, styles.expenseWidgetRadius] : []; return ( {shouldUseNarrowLayout ? ( - + {shouldShowCheckbox && ( From 44ae0bb59a1930213183e33c835867a34a75a5cd Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Wed, 28 May 2025 16:05:39 +0200 Subject: [PATCH 02/21] fix uneven columns in Reports page --- src/CONST.ts | 1 + src/components/SelectionList/SearchTableHeader.tsx | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/CONST.ts b/src/CONST.ts index 7a8635895071..de3cd590bf21 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -6605,6 +6605,7 @@ const CONST = { TITLE: 'title', ASSIGNEE: 'assignee', CREATED_BY: 'createdBy', + COMMENTS: 'comments', IN: 'in', }, SYNTAX_OPERATORS: { diff --git a/src/components/SelectionList/SearchTableHeader.tsx b/src/components/SelectionList/SearchTableHeader.tsx index b7227ede9a6f..2c7a8f8f7a62 100644 --- a/src/components/SelectionList/SearchTableHeader.tsx +++ b/src/components/SelectionList/SearchTableHeader.tsx @@ -35,7 +35,7 @@ const shouldShowColumnConfig: Record true, [CONST.SEARCH.TABLE_COLUMNS.IN]: () => true, // This column is never displayed on Search - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: () => false, + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: () => true, }; const expenseHeaders: SearchColumnConfig[] = [ @@ -82,6 +82,11 @@ const expenseHeaders: SearchColumnConfig[] = [ translationKey: 'common.tax', isColumnSortable: false, }, + { + columnName: CONST.SEARCH.TABLE_COLUMNS.COMMENTS, + translationKey: '', + isColumnSortable: false, + }, { columnName: CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT, translationKey: 'common.total', From 03952b40d14e96994def37946b7c9e12d87cf51e Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Thu, 29 May 2025 12:52:25 +0200 Subject: [PATCH 03/21] clean up ReportListItem and TransactionListItem --- .../SelectionList/Search/ReportListItem.tsx | 1 - .../Search/ReportListItemHeader.tsx | 110 +++++------------- .../Search/TransactionListItem.tsx | 34 +++--- .../Search/UserInfoAndActionButtonRow.tsx | 21 +++- tests/ui/ReportListItemHeaderTest.tsx | 6 +- 5 files changed, 64 insertions(+), 108 deletions(-) diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index b666d789c424..6aa5bcbbc831 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -130,7 +130,6 @@ function ReportListItem({ = { /** The report currently being looked at */ - report: OnyxEntry; + report: ReportListItemType; /** The policy tied to the expense report */ policy: OnyxEntry; - /** The section list item */ - item: TItem; - /** Callback to fire when the item is pressed */ onSelectRow: (item: TItem) => void; @@ -51,14 +46,11 @@ type ReportListItemHeaderProps = { type FirstRowReportHeaderProps = { /** The report currently being looked at */ - report: OnyxEntry; + report: ReportListItemType; /** The policy tied to the expense report */ policy: OnyxEntry; - /** The section list item */ - item: TItem; - /** Callback to fire when a checkbox is pressed */ onCheckboxPress?: (item: TItem) => void; @@ -104,8 +96,7 @@ function TotalCell({showTooltip, isLargeScreenWidth, reportItem}: ReportCellProp function FirstHeaderRow({ policy, - report: moneyRequestReport, - item, + report: reportItem, onCheckboxPress, isDisabled, canSelectMultiple, @@ -115,25 +106,24 @@ function FirstHeaderRow({ }: FirstRowReportHeaderProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); - const reportItem = item as unknown as ReportListItemType; return ( - + {!!canSelectMultiple && ( onCheckboxPress?.(item)} - isChecked={item.isSelected} - containerStyle={[StyleUtils.getCheckboxContainerStyle(20), StyleUtils.getMultiselectListStyles(!!item.isSelected, !!item.isDisabled)]} - disabled={!!isDisabled || item.isDisabledCheckbox} - accessibilityLabel={item.text ?? ''} + onPress={() => onCheckboxPress?.(reportItem as unknown as TItem)} + isChecked={reportItem.isSelected} + containerStyle={[StyleUtils.getCheckboxContainerStyle(20), StyleUtils.getMultiselectListStyles(!!reportItem.isSelected, !!reportItem.isDisabled)]} + disabled={!!isDisabled || reportItem.isDisabledCheckbox} + accessibilityLabel={reportItem.text ?? ''} shouldStopMouseDownPropagation - style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), item.isDisabledCheckbox && styles.cursorDisabled]} + style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), reportItem.isDisabledCheckbox && styles.cursorDisabled]} /> )} ({ @@ -164,8 +154,7 @@ function FirstHeaderRow({ function ReportListItemHeader({ policy, - report: moneyRequestReport, - item, + report: reportItem, onSelectRow, onCheckboxPress, isDisabled, @@ -176,79 +165,38 @@ function ReportListItemHeader({ const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const theme = useTheme(); - const reportItem = item as unknown as ReportListItemType; const {currentSearchHash} = useSearchContext(); - const {translate} = useLocalize(); const {isLargeScreenWidth} = useResponsiveLayout(); const thereIsFromAndTo = !!reportItem?.from && !!reportItem?.to; - const showArrowComponent = (reportItem.type === CONST.REPORT.TYPE.IOU && thereIsFromAndTo) || (reportItem.type === CONST.REPORT.TYPE.EXPENSE && !!reportItem?.from); - const participantToDisplayName = useMemo( - () => reportItem?.to?.displayName ?? reportItem?.to?.login ?? translate('common.hidden'), - [reportItem?.to?.displayName, reportItem?.to?.login, translate], - ); - const shouldShowToRecipient = useMemo( - () => thereIsFromAndTo && !!reportItem?.to?.accountID && reportItem?.from?.accountID !== reportItem?.to?.accountID && !!isCorrectSearchUserName(participantToDisplayName), - [thereIsFromAndTo, reportItem?.from?.accountID, reportItem?.to?.accountID, participantToDisplayName], - ); + const showUserInfo = (reportItem.type === CONST.REPORT.TYPE.IOU && thereIsFromAndTo) || (reportItem.type === CONST.REPORT.TYPE.EXPENSE && !!reportItem?.from); + const avatarBorderColor = - StyleUtils.getItemBackgroundColorStyle(!!item.isSelected, !!isFocused || !!isHovered, !!isDisabled, theme.activeComponentBG, theme.hoverComponentBG)?.backgroundColor ?? + StyleUtils.getItemBackgroundColorStyle(!!reportItem.isSelected, !!isFocused || !!isHovered, !!isDisabled, theme.activeComponentBG, theme.hoverComponentBG)?.backgroundColor ?? theme.highlightBG; const handleOnButtonPress = () => { - handleActionButtonPress(currentSearchHash, reportItem, () => onSelectRow(item)); + handleActionButtonPress(currentSearchHash, reportItem, () => onSelectRow(reportItem as unknown as TItem)); }; return !isLargeScreenWidth ? ( - + - - - {showArrowComponent && ( - - )} - - - - - + ) : ( - + ({ handleOnButtonPress={handleOnButtonPress} avatarBorderColor={avatarBorderColor} /> - + diff --git a/src/components/SelectionList/Search/TransactionListItem.tsx b/src/components/SelectionList/Search/TransactionListItem.tsx index 3381ebfe21ad..6f8bbca8c236 100644 --- a/src/components/SelectionList/Search/TransactionListItem.tsx +++ b/src/components/SelectionList/Search/TransactionListItem.tsx @@ -62,21 +62,24 @@ function TransactionListItem({ return shouldShowYearForSomeTransaction ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL; }, [transactionItem]); - const {COLUMNS} = CONST.REPORT.TRANSACTION_LIST; - - const columns = [ - COLUMNS.RECEIPT, - COLUMNS.TYPE, - COLUMNS.DATE, - COLUMNS.MERCHANT, - COLUMNS.FROM, - COLUMNS.TO, - ...(transactionItem?.shouldShowCategory ? [COLUMNS.CATEGORY] : []), - ...(transactionItem?.shouldShowTag ? [COLUMNS.TAG] : []), - ...(transactionItem?.shouldShowTax ? [COLUMNS.TAX] : []), - COLUMNS.TOTAL_AMOUNT, - COLUMNS.ACTION, - ] as Array>; + const columns = useMemo( + () => + [ + CONST.REPORT.TRANSACTION_LIST.COLUMNS.RECEIPT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TYPE, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.DATE, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.FROM, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO, + ...(transactionItem?.shouldShowCategory ? [CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY] : []), + ...(transactionItem?.shouldShowTag ? [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAG] : []), + ...(transactionItem?.shouldShowTax ? [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAX] : []), + CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT, + CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION, + ] as Array>, + [transactionItem?.shouldShowCategory, transactionItem?.shouldShowTag, transactionItem?.shouldShowTax], + ); return ( ({ handleActionButtonPress={() => { handleActionButtonPress(currentSearchHash, transactionItem, () => onSelectRow(item)); }} + shouldShowUserInfo={!!transactionItem?.from} /> )} void}) { +function UserInfoAndActionButtonRow({ + item, + handleActionButtonPress, + shouldShowUserInfo, +}: { + item: ReportListItemType | TransactionListItemType; + handleActionButtonPress: () => void; + shouldShowUserInfo: boolean; +}) { const {translate} = useLocalize(); const styles = useThemeStyles(); const hasFromSender = !!item?.from && !!item?.from?.accountID && !!item?.from?.displayName; const hasToRecipent = !!item?.to && !!item?.to?.accountID && !!item?.to?.displayName; - const showArrowComponent = hasFromSender || hasToRecipent; - const shouldShowToRecipient = hasFromSender && hasToRecipent && item?.from?.accountID !== item?.to?.accountID; + const participantToDisplayName = item?.to?.displayName ?? item?.to?.login ?? translate('common.hidden'); + const shouldShowToRecipient = + hasFromSender && hasToRecipent && !!item?.to?.accountID && item?.from?.accountID !== item?.to?.accountID && !!isCorrectSearchUserName(participantToDisplayName); return ( - + - {showArrowComponent && ( + {shouldShowUserInfo && ( , from?: st // Helper function to wrap component with context const renderReportListItemHeader = (reportItem: ReportListItemType) => { - const mockReport = createRandomReport(Number(reportItem.reportID)); - return render( {/* @ts-expect-error - Disable TypeScript errors to simplify the test */} Date: Thu, 29 May 2025 12:53:22 +0200 Subject: [PATCH 04/21] remove TransactionListItemRow --- .../Search/TransactionListItemRow.tsx | 475 ------------------ 1 file changed, 475 deletions(-) delete mode 100644 src/components/SelectionList/Search/TransactionListItemRow.tsx diff --git a/src/components/SelectionList/Search/TransactionListItemRow.tsx b/src/components/SelectionList/Search/TransactionListItemRow.tsx deleted file mode 100644 index 16ff60fdb7a2..000000000000 --- a/src/components/SelectionList/Search/TransactionListItemRow.tsx +++ /dev/null @@ -1,475 +0,0 @@ -import {Str} from 'expensify-common'; -import React from 'react'; -import type {StyleProp, ViewStyle} from 'react-native'; -import {View} from 'react-native'; -import {getButtonRole} from '@components/Button/utils'; -import Checkbox from '@components/Checkbox'; -import Icon from '@components/Icon'; -import * as Expensicons from '@components/Icon/Expensicons'; -import {PressableWithFeedback} from '@components/Pressable'; -import ReceiptImage from '@components/ReceiptImage'; -import type {TransactionListItemType} from '@components/SelectionList/types'; -import TextWithTooltip from '@components/TextWithTooltip'; -import Tooltip from '@components/Tooltip'; -import useLocalize from '@hooks/useLocalize'; -import useResponsiveLayout from '@hooks/useResponsiveLayout'; -import useStyleUtils from '@hooks/useStyleUtils'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; -import {convertToDisplayString} from '@libs/CurrencyUtils'; -import {getFileName} from '@libs/fileDownload/FileUtils'; -import Parser from '@libs/Parser'; -import {getThumbnailAndImageURIs} from '@libs/ReceiptUtils'; -import StringUtils from '@libs/StringUtils'; -import { - getCreated, - getTagForDisplay, - getTaxAmount, - getCurrency as getTransactionCurrency, - getDescription as getTransactionDescription, - hasReceipt, - hasReceiptSource, - isExpensifyCardTransaction, - isPending, - isReceiptBeingScanned, -} from '@libs/TransactionUtils'; -import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot'; -import variables from '@styles/variables'; -import CONST from '@src/CONST'; -import type {SearchTransactionType} from '@src/types/onyx/SearchResults'; -import ActionCell from './ActionCell'; -import DateCell from './DateCell'; -import ExpenseItemHeaderNarrow from './ExpenseItemHeaderNarrow'; -import TextWithIconCell from './TextWithIconCell'; -import UserInfoCell from './UserInfoCell'; - -type CellProps = { - // eslint-disable-next-line react/no-unused-prop-types - showTooltip: boolean; - // eslint-disable-next-line react/no-unused-prop-types - isLargeScreenWidth: boolean; -}; - -type TransactionCellProps = { - transactionItem: TransactionListItemType; -} & CellProps; - -type TotalCellProps = { - // eslint-disable-next-line react/no-unused-prop-types - isChildListItem: boolean; -} & TransactionCellProps; - -type TransactionListItemRowProps = { - item: TransactionListItemType; - showTooltip: boolean; - onButtonPress: () => void; - onCheckboxPress: () => void; - showItemHeaderOnNarrowLayout?: boolean; - containerStyle?: StyleProp; - isChildListItem?: boolean; - isDisabled: boolean; - canSelectMultiple: boolean; - isButtonSelected?: boolean; - parentAction?: string; - shouldShowTransactionCheckbox?: boolean; - isLoading?: boolean; -}; - -const getTypeIcon = (type?: SearchTransactionType) => { - switch (type) { - case CONST.SEARCH.TRANSACTION_TYPE.CASH: - return Expensicons.Cash; - case CONST.SEARCH.TRANSACTION_TYPE.CARD: - return Expensicons.CreditCard; - case CONST.SEARCH.TRANSACTION_TYPE.DISTANCE: - return Expensicons.Car; - default: - return Expensicons.Cash; - } -}; - -function ReceiptCell({transactionItem}: TransactionCellProps) { - const theme = useTheme(); - const styles = useThemeStyles(); - const StyleUtils = useStyleUtils(); - - const backgroundStyles = transactionItem.isSelected ? StyleUtils.getBackgroundColorStyle(theme.buttonHoveredBG) : StyleUtils.getBackgroundColorStyle(theme.border); - - let source = transactionItem?.receipt?.source ?? ''; - if (source && typeof source === 'string') { - const filename = getFileName(source); - const receiptURIs = getThumbnailAndImageURIs(transactionItem, null, filename); - const isReceiptPDF = Str.isPDF(filename); - source = tryResolveUrlFromApiRoot(isReceiptPDF && !receiptURIs.isLocalFile ? receiptURIs.thumbnail ?? '' : receiptURIs.image ?? ''); - } - - return ( - - - - ); -} - -function MerchantCell({transactionItem, showTooltip, isLargeScreenWidth}: TransactionCellProps) { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - const description = getTransactionDescription(transactionItem); - let merchantOrDescriptionToDisplay = transactionItem.formattedMerchant; - if (!merchantOrDescriptionToDisplay && !isLargeScreenWidth) { - merchantOrDescriptionToDisplay = Parser.htmlToText(description); - } - let merchant = transactionItem.shouldShowMerchant ? merchantOrDescriptionToDisplay : Parser.htmlToText(description); - - if (hasReceipt(transactionItem) && isReceiptBeingScanned(transactionItem) && transactionItem.shouldShowMerchant) { - merchant = translate('iou.receiptStatusTitle'); - } - const merchantToDisplay = StringUtils.getFirstLine(merchant); - return ( - - ); -} - -function TotalCell({showTooltip, isLargeScreenWidth, transactionItem}: TotalCellProps) { - const styles = useThemeStyles(); - const {translate} = useLocalize(); - const currency = getTransactionCurrency(transactionItem); - let amount = convertToDisplayString(transactionItem.formattedTotal, currency); - - if (hasReceipt(transactionItem) && isReceiptBeingScanned(transactionItem)) { - amount = translate('iou.receiptStatusTitle'); - } - - return ( - - ); -} - -function TypeCell({transactionItem, isLargeScreenWidth}: TransactionCellProps) { - const theme = useTheme(); - const {translate} = useLocalize(); - const isPendingExpensifyCardTransaction = isExpensifyCardTransaction(transactionItem) && isPending(transactionItem); - const typeIcon = isPendingExpensifyCardTransaction ? Expensicons.CreditCardHourglass : getTypeIcon(transactionItem.transactionType); - - const tooltipText = isPendingExpensifyCardTransaction ? translate('iou.pending') : ''; - - return ( - - - - - - ); -} - -function CategoryCell({isLargeScreenWidth, showTooltip, transactionItem}: TransactionCellProps) { - const styles = useThemeStyles(); - return ( - - ); -} - -function TagCell({isLargeScreenWidth, showTooltip, transactionItem}: TransactionCellProps) { - const styles = useThemeStyles(); - return isLargeScreenWidth ? ( - - ) : ( - - ); -} - -function TaxCell({transactionItem, showTooltip}: TransactionCellProps) { - const styles = useThemeStyles(); - - const isFromExpenseReport = transactionItem.reportType === CONST.REPORT.TYPE.EXPENSE; - const taxAmount = getTaxAmount(transactionItem, isFromExpenseReport); - const currency = getTransactionCurrency(transactionItem); - - return ( - - ); -} - -function TransactionListItemRow({ - item, - showTooltip, - isDisabled, - canSelectMultiple, - onButtonPress, - onCheckboxPress, - showItemHeaderOnNarrowLayout = true, - containerStyle, - isChildListItem = false, - isButtonSelected = false, - parentAction = '', - shouldShowTransactionCheckbox, - isLoading = false, -}: TransactionListItemRowProps) { - const styles = useThemeStyles(); - const {isLargeScreenWidth} = useResponsiveLayout(); - const StyleUtils = useStyleUtils(); - const theme = useTheme(); - - const created = getCreated(item); - - if (!isLargeScreenWidth) { - return ( - - {showItemHeaderOnNarrowLayout && ( - - )} - - - {canSelectMultiple && !!shouldShowTransactionCheckbox && ( - - - {!!item.isSelected && ( - - )} - - - )} - - - - {!!item.category && ( - - - - )} - - - - - - - - - - - ); - } - - return ( - - {canSelectMultiple && ( - - )} - - - - - - - - - - - - - - - - - - - - {item.shouldShowCategory && ( - - - - )} - {item.shouldShowTag && ( - - - - )} - {item.shouldShowTax && ( - - - - )} - - - - - - - - - - ); -} - -TransactionListItemRow.displayName = 'TransactionListItemRow'; - -export default TransactionListItemRow; From 94d226d7841fba6be369dae9adcc69ceb6017be0 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Thu, 29 May 2025 13:22:25 +0200 Subject: [PATCH 05/21] refactor TransactionItemRow type --- .../Search/TransactionListItem.tsx | 1 - src/components/TransactionItemRow/index.tsx | 42 +++++++++---------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/components/SelectionList/Search/TransactionListItem.tsx b/src/components/SelectionList/Search/TransactionListItem.tsx index 6f8bbca8c236..0bfa6677a2d0 100644 --- a/src/components/SelectionList/Search/TransactionListItem.tsx +++ b/src/components/SelectionList/Search/TransactionListItem.tsx @@ -127,7 +127,6 @@ function TransactionListItem({ shouldShowCheckbox={!!canSelectMultiple} columnWrapperStyles={[styles.ph3, styles.pv1half]} isChildListItem={false} - usedInExpenses /> )} diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 9410a7b6ef0e..4575e3cf4721 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -51,6 +51,24 @@ type TransactionWithOptionalSearchFields = TransactionWithOptionalHighlight & { transactionType?: ValueOf; }; +type TransactionItemRowProps = { + transactionItem: TransactionWithOptionalSearchFields; + shouldUseNarrowLayout: boolean; + isSelected: boolean; + shouldShowTooltip: boolean; + dateColumnSize: TableColumnSize; + onCheckboxPress: (transactionID: string) => void; + shouldShowCheckbox: boolean; + columns?: Array>; + onButtonPress?: () => void; + isParentHovered?: boolean; + columnWrapperStyles?: ViewStyle[]; + scrollToNewTransaction?: ((offset: number) => void) | undefined; + isChildListItem?: boolean; + isActionLoading?: boolean; + isInReportRow?: boolean; +}; + function TransactionItemRow({ transactionItem, shouldUseNarrowLayout, @@ -66,26 +84,8 @@ function TransactionItemRow({ scrollToNewTransaction, isChildListItem = true, isActionLoading, - usedInExpenses, isInReportRow = false, -}: { - transactionItem: TransactionWithOptionalSearchFields; - shouldUseNarrowLayout: boolean; - isSelected: boolean; - shouldShowTooltip: boolean; - dateColumnSize: TableColumnSize; - onCheckboxPress: (transactionID: string) => void; - shouldShowCheckbox: boolean; - columns?: Array>; - onButtonPress?: () => void; - isParentHovered?: boolean; - columnWrapperStyles?: ViewStyle[]; - scrollToNewTransaction?: ((offset: number) => void) | undefined; - isChildListItem?: boolean; - isActionLoading?: boolean; - usedInExpenses?: boolean; - isInReportRow?: boolean; -}) { +}: TransactionItemRowProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); const theme = useTheme(); @@ -244,7 +244,7 @@ function TransactionItemRow({ }), [StyleUtils, createdAt, isActionLoading, isChildListItem, isDateColumnWide, isSelected, onButtonPress, shouldShowTooltip, shouldUseNarrowLayout, transactionItem], ); - const safeColumnWrapperStyle = !usedInExpenses ? columnWrapperStyles ?? [styles.p3, styles.expenseWidgetRadius] : []; + const safeColumnWrapperStyle = isInReportRow ? columnWrapperStyles ?? [styles.p3, styles.expenseWidgetRadius] : []; return ( {shouldUseNarrowLayout ? ( - + {shouldShowCheckbox && ( From 204be2f492832cefb1e6bc946818c4ffccb23e88 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Thu, 29 May 2025 14:03:46 +0200 Subject: [PATCH 06/21] fix violation message overflowing chat bubble --- src/components/TransactionItemRow/TransactionItemRowRBR.tsx | 2 +- src/components/TransactionItemRow/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/TransactionItemRow/TransactionItemRowRBR.tsx b/src/components/TransactionItemRow/TransactionItemRowRBR.tsx index 5828fd1ab1cc..ae493d5ebe33 100644 --- a/src/components/TransactionItemRow/TransactionItemRowRBR.tsx +++ b/src/components/TransactionItemRow/TransactionItemRowRBR.tsx @@ -92,7 +92,7 @@ function TransactionItemRowRBR({transaction, containerStyles}: TransactionItemRo ].join(' '); return ( RBRMessages.length > 0 && ( - + - + {hasCategoryOrTag && ( Date: Thu, 29 May 2025 16:36:34 +0200 Subject: [PATCH 07/21] fix higlight new transactions highlight bug --- .../MoneyRequestReportTransactionList.tsx | 1 + .../SelectionList/Search/ReportListItem.tsx | 1 - .../SelectionList/Search/ReportListItemHeader.tsx | 8 ++++---- .../SelectionList/Search/TransactionListItem.tsx | 6 +++--- .../Search/UserInfoAndActionButtonRow.tsx | 2 +- src/components/TransactionItemRow/index.tsx | 12 ++++++------ 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx index 07b0e67ffe3a..bdf1072b526c 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx @@ -286,6 +286,7 @@ function MoneyRequestReportTransactionList({ onCheckboxPress={toggleTransaction} columns={allReportColumns} scrollToNewTransaction={transaction.transactionID === newTransactions?.at(0)?.transactionID ? scrollToNewTransaction : undefined} + shouldUseAnimatedHighlight /> ); diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index 6aa5bcbbc831..71fc57fa2eaa 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -163,7 +163,6 @@ function ReportListItem({ }} isParentHovered={hovered} columnWrapperStyles={[styles.ph3, styles.pv1half]} - isInReportRow /> )) diff --git a/src/components/SelectionList/Search/ReportListItemHeader.tsx b/src/components/SelectionList/Search/ReportListItemHeader.tsx index 8c1d9ce00a88..b441ed7ec25e 100644 --- a/src/components/SelectionList/Search/ReportListItemHeader.tsx +++ b/src/components/SelectionList/Search/ReportListItemHeader.tsx @@ -108,7 +108,7 @@ function FirstHeaderRow({ const StyleUtils = useStyleUtils(); return ( - + {!!canSelectMultiple && ( ({ handleActionButtonPress(currentSearchHash, reportItem, () => onSelectRow(reportItem as unknown as TItem)); }; return !isLargeScreenWidth ? ( - + ({ /> ) : ( - + ({ handleOnButtonPress={handleOnButtonPress} avatarBorderColor={avatarBorderColor} /> - + diff --git a/src/components/SelectionList/Search/TransactionListItem.tsx b/src/components/SelectionList/Search/TransactionListItem.tsx index 0bfa6677a2d0..882cb3172f29 100644 --- a/src/components/SelectionList/Search/TransactionListItem.tsx +++ b/src/components/SelectionList/Search/TransactionListItem.tsx @@ -36,8 +36,9 @@ function TransactionListItem({ const listItemPressableStyle = [ styles.selectionListPressableItemWrapper, - styles.pv3, - styles.ph3, + styles.pv0, + !isLargeScreenWidth && styles.pt3, + styles.ph0, // Removing background style because they are added to the parent OpacityView via animatedHighlightStyle styles.bgTransparent, item.isSelected && styles.activeComponentBG, @@ -125,7 +126,6 @@ function TransactionListItem({ isSelected={!!transactionItem.isSelected} dateColumnSize={dateColumnSize} shouldShowCheckbox={!!canSelectMultiple} - columnWrapperStyles={[styles.ph3, styles.pv1half]} isChildListItem={false} /> diff --git a/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx b/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx index 3206fbe5f1b2..fe7334285cde 100644 --- a/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx +++ b/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx @@ -25,7 +25,7 @@ function UserInfoAndActionButtonRow({ hasFromSender && hasToRecipent && !!item?.to?.accountID && item?.from?.accountID !== item?.to?.accountID && !!isCorrectSearchUserName(participantToDisplayName); return ( - + {shouldShowUserInfo && ( void) | undefined; isChildListItem?: boolean; isActionLoading?: boolean; - isInReportRow?: boolean; + shouldUseAnimatedHighlight?: boolean; }; function TransactionItemRow({ @@ -84,7 +84,7 @@ function TransactionItemRow({ scrollToNewTransaction, isChildListItem = true, isActionLoading, - isInReportRow = false, + shouldUseAnimatedHighlight = false, }: TransactionItemRowProps) { const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); @@ -244,7 +244,7 @@ function TransactionItemRow({ }), [StyleUtils, createdAt, isActionLoading, isChildListItem, isDateColumnWide, isSelected, onButtonPress, shouldShowTooltip, shouldUseNarrowLayout, transactionItem], ); - const safeColumnWrapperStyle = isInReportRow ? columnWrapperStyles ?? [styles.p3, styles.expenseWidgetRadius] : []; + const safeColumnWrapperStyle = columnWrapperStyles ?? [styles.p3, styles.expenseWidgetRadius]; return ( {shouldUseNarrowLayout ? ( - - + + {shouldShowCheckbox && ( @@ -345,7 +345,7 @@ function TransactionItemRow({ ) : ( - + From 2b563097873959b257a38435554a6bc0693a5844 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Fri, 30 May 2025 10:01:19 +0200 Subject: [PATCH 08/21] fix PR comments --- src/components/SelectionList/SearchTableHeader.tsx | 7 +------ src/components/TransactionItemRow/index.tsx | 12 ++++++------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/components/SelectionList/SearchTableHeader.tsx b/src/components/SelectionList/SearchTableHeader.tsx index 2c7a8f8f7a62..b7227ede9a6f 100644 --- a/src/components/SelectionList/SearchTableHeader.tsx +++ b/src/components/SelectionList/SearchTableHeader.tsx @@ -35,7 +35,7 @@ const shouldShowColumnConfig: Record true, [CONST.SEARCH.TABLE_COLUMNS.IN]: () => true, // This column is never displayed on Search - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: () => true, + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: () => false, }; const expenseHeaders: SearchColumnConfig[] = [ @@ -82,11 +82,6 @@ const expenseHeaders: SearchColumnConfig[] = [ translationKey: 'common.tax', isColumnSortable: false, }, - { - columnName: CONST.SEARCH.TABLE_COLUMNS.COMMENTS, - translationKey: '', - isColumnSortable: false, - }, { columnName: CONST.SEARCH.TABLE_COLUMNS.TOTAL_AMOUNT, translationKey: 'common.total', diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 7690ba8db2b9..d4597ba0e1bf 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -201,9 +201,9 @@ function TransactionItemRow({ {!!transactionItem.to && ( )} @@ -212,9 +212,9 @@ function TransactionItemRow({ {!!transactionItem.from && ( )} From 767000b4d9ab2d7b5abdd3332027adc27deb8d5d Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Fri, 30 May 2025 15:33:47 +0200 Subject: [PATCH 09/21] fix MerchantCell and Type cell to match the Reports > Expenses requirements --- .../Search/TransactionListItem.tsx | 1 - src/components/SelectionList/types.ts | 2 +- .../DataCells/MerchantCell.tsx | 44 +++++++++++--- .../TransactionItemRow/DataCells/TypeCell.tsx | 6 +- src/components/TransactionItemRow/index.tsx | 59 ++++++++++++++----- 5 files changed, 83 insertions(+), 29 deletions(-) diff --git a/src/components/SelectionList/Search/TransactionListItem.tsx b/src/components/SelectionList/Search/TransactionListItem.tsx index 882cb3172f29..4390fc95ec13 100644 --- a/src/components/SelectionList/Search/TransactionListItem.tsx +++ b/src/components/SelectionList/Search/TransactionListItem.tsx @@ -75,7 +75,6 @@ function TransactionListItem({ ...(transactionItem?.shouldShowCategory ? [CONST.REPORT.TRANSACTION_LIST.COLUMNS.CATEGORY] : []), ...(transactionItem?.shouldShowTag ? [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAG] : []), ...(transactionItem?.shouldShowTax ? [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAX] : []), - CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS, CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT, CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION, ] as Array>, diff --git a/src/components/SelectionList/types.ts b/src/components/SelectionList/types.ts index 8cea5d2d33ee..bea23495fa57 100644 --- a/src/components/SelectionList/types.ts +++ b/src/components/SelectionList/types.ts @@ -815,7 +815,7 @@ type ExtendedSectionListData = ExtendedSectionListData>; -type SortableColumnName = SearchColumnType | typeof CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS; +type SortableColumnName = SearchColumnType; type SearchListItem = TransactionListItemType | ReportListItemType | ReportActionListItemType | TaskListItemType; diff --git a/src/components/TransactionItemRow/DataCells/MerchantCell.tsx b/src/components/TransactionItemRow/DataCells/MerchantCell.tsx index 092c8a84e83d..6b33cf90c2e8 100644 --- a/src/components/TransactionItemRow/DataCells/MerchantCell.tsx +++ b/src/components/TransactionItemRow/DataCells/MerchantCell.tsx @@ -1,24 +1,50 @@ import React from 'react'; import TextWithTooltip from '@components/TextWithTooltip'; import useThemeStyles from '@hooks/useThemeStyles'; -import {getMerchant} from '@libs/TransactionUtils'; +import Parser from '@libs/Parser'; +import StringUtils from '@libs/StringUtils'; +import {getDescription, getMerchant, hasReceipt, isReceiptBeingScanned} from '@libs/TransactionUtils'; import CONST from '@src/CONST'; -import type TransactionDataCellProps from './TransactionDataCellProps'; +import type {TranslationPaths} from '@src/languages/types'; +import type {TransactionWithOptionalSearchFields} from '..'; -function MerchantCell({transactionItem, shouldShowTooltip, shouldUseNarrowLayout}: TransactionDataCellProps) { - const styles = useThemeStyles(); +/** If merchant name is empty or (none), then it it falls back to description if screen is narrow */ +function getMerchantNameWithFallback(transactionItem: TransactionWithOptionalSearchFields, translate: (key: TranslationPaths) => string, shouldUseNarrowLayout?: boolean | undefined) { + const shouldShowMerchant = transactionItem.shouldShowMerchant ?? true; + const description = getDescription(transactionItem); + let merchantOrDescriptionToDisplay = transactionItem?.formattedMerchant ?? getMerchant(transactionItem); + if ((!merchantOrDescriptionToDisplay || merchantOrDescriptionToDisplay === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT) && shouldUseNarrowLayout) { + merchantOrDescriptionToDisplay = Parser.htmlToText(description); + } + let merchant = shouldShowMerchant ? merchantOrDescriptionToDisplay : Parser.htmlToText(description); + + if (hasReceipt(transactionItem) && isReceiptBeingScanned(transactionItem) && shouldShowMerchant) { + merchant = translate('iou.receiptStatusTitle'); + } + const merchantName = StringUtils.getFirstLine(merchant); + return merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT ? merchantName : ''; +} - const merchantName = getMerchant(transactionItem); - const merchantToDisplay = merchantName === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT ? '' : merchantName; +function MerchantOrDescriptionCell({ + merchantOrDescription, + shouldShowTooltip, + shouldUseNarrowLayout, +}: { + merchantOrDescription: string; + shouldUseNarrowLayout?: boolean | undefined; + shouldShowTooltip: boolean; +}) { + const styles = useThemeStyles(); return ( ); } -MerchantCell.displayName = 'MerchantCell'; -export default MerchantCell; +MerchantOrDescriptionCell.displayName = 'MerchantOrDescriptionCell'; +export default MerchantOrDescriptionCell; +export {getMerchantNameWithFallback}; diff --git a/src/components/TransactionItemRow/DataCells/TypeCell.tsx b/src/components/TransactionItemRow/DataCells/TypeCell.tsx index 2a9996b7d7a5..f22d335ec155 100644 --- a/src/components/TransactionItemRow/DataCells/TypeCell.tsx +++ b/src/components/TransactionItemRow/DataCells/TypeCell.tsx @@ -5,6 +5,7 @@ import TextWithTooltip from '@components/TextWithTooltip'; import useLocalize from '@hooks/useLocalize'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import {isExpensifyCardTransaction, isPending} from '@libs/TransactionUtils'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import type TransactionDataCellProps from './TransactionDataCellProps'; @@ -48,8 +49,9 @@ function TypeCell({transactionItem, shouldUseNarrowLayout, shouldShowTooltip}: T const {translate} = useLocalize(); const theme = useTheme(); const type = transactionItem.transactionType ?? getType(transactionItem.cardName); - const typeIcon = getTypeIcon(type); - const typeText = getTypeText(type); + const isPendingExpensifyCardTransaction = isExpensifyCardTransaction(transactionItem) && isPending(transactionItem); + const typeIcon = isPendingExpensifyCardTransaction ? Expensicons.CreditCardHourglass : getTypeIcon(type); + const typeText = isPendingExpensifyCardTransaction ? 'iou.pending' : getTypeText(type); const styles = useThemeStyles(); return shouldUseNarrowLayout ? ( diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index d4597ba0e1bf..56c28a92d4ad 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -13,16 +13,17 @@ import UserInfoCell from '@components/SelectionList/Search/UserInfoCell'; import Text from '@components/Text'; import useAnimatedHighlightStyle from '@hooks/useAnimatedHighlightStyle'; import useHover from '@hooks/useHover'; +import useLocalize from '@hooks/useLocalize'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import {getMerchant, getCreated as getTransactionCreated, getTransactionPendingAction, isPartialMerchant} from '@libs/TransactionUtils'; +import {getCreated as getTransactionCreated, getTransactionPendingAction} from '@libs/TransactionUtils'; import variables from '@styles/variables'; import CONST from '@src/CONST'; import type {SearchPersonalDetails, SearchTransactionAction} from '@src/types/onyx/SearchResults'; import CategoryCell from './DataCells/CategoryCell'; import ChatBubbleCell from './DataCells/ChatBubbleCell'; -import MerchantCell from './DataCells/MerchantCell'; +import MerchantOrDescriptionCell, {getMerchantNameWithFallback} from './DataCells/MerchantCell'; import ReceiptCell from './DataCells/ReceiptCell'; import TagCell from './DataCells/TagCell'; import TaxCell from './DataCells/TaxCell'; @@ -47,6 +48,18 @@ type TransactionWithOptionalSearchFields = TransactionWithOptionalHighlight & { /** The personal details of the user paying the request */ to?: SearchPersonalDetails; + /** formatted "to" value used for displaying and sorting on Reports page */ + formattedTo?: string; + + /** formatted "from" value used for displaying and sorting on Reports page */ + formattedFrom?: string; + + /** formatted "merchant" value used for displaying and sorting on Reports page */ + formattedMerchant?: string; + + /** information about whether to show merchant, that is provided on Reports page */ + shouldShowMerchant?: boolean; + /** Type of transaction */ transactionType?: ValueOf; }; @@ -87,6 +100,7 @@ function TransactionItemRow({ shouldUseAnimatedHighlight = false, }: TransactionItemRowProps) { const styles = useThemeStyles(); + const {translate} = useLocalize(); const StyleUtils = useStyleUtils(); const theme = useTheme(); const pendingAction = getTransactionPendingAction(transactionItem); @@ -115,8 +129,7 @@ function TransactionItemRow({ } }, [hovered, isParentHovered, isSelected, styles.activeComponentBG, styles.hoveredComponentBG]); - const merchantName = getMerchant(transactionItem); - const isMerchantEmpty = isPartialMerchant(merchantName); + const merchantOrDescriptionName = getMerchantNameWithFallback(transactionItem, translate, shouldUseNarrowLayout); useEffect(() => { if (!transactionItem.shouldBeHighlighted || !scrollToNewTransaction) { @@ -190,11 +203,13 @@ function TransactionItemRow({ ), [CONST.REPORT.TRANSACTION_LIST.COLUMNS.MERCHANT]: ( - + {!!merchantOrDescriptionName && ( + + )} ), [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TO]: ( @@ -203,7 +218,7 @@ function TransactionItemRow({ )} @@ -214,7 +229,7 @@ function TransactionItemRow({ )} @@ -242,7 +257,19 @@ function TransactionItemRow({ ), }), - [StyleUtils, createdAt, isActionLoading, isChildListItem, isDateColumnWide, isSelected, onButtonPress, shouldShowTooltip, shouldUseNarrowLayout, transactionItem], + [ + StyleUtils, + createdAt, + isActionLoading, + isChildListItem, + isDateColumnWide, + isSelected, + merchantOrDescriptionName, + onButtonPress, + shouldShowTooltip, + shouldUseNarrowLayout, + transactionItem, + ], ); const safeColumnWrapperStyle = columnWrapperStyles ?? [styles.p3, styles.expenseWidgetRadius]; return ( @@ -290,7 +317,7 @@ function TransactionItemRow({ shouldShowTooltip={shouldShowTooltip} shouldUseNarrowLayout={shouldUseNarrowLayout} /> - {isMerchantEmpty && ( + {!merchantOrDescriptionName && ( )} - {!isMerchantEmpty && ( + {!!merchantOrDescriptionName && ( - From 3dc032bd78ce26da71962d090724b94890c5ca4d Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Fri, 30 May 2025 15:34:07 +0200 Subject: [PATCH 10/21] remove unused components --- .../Search/ExpenseItemHeaderNarrow.tsx | 106 ------------------ 1 file changed, 106 deletions(-) delete mode 100644 src/components/SelectionList/Search/ExpenseItemHeaderNarrow.tsx diff --git a/src/components/SelectionList/Search/ExpenseItemHeaderNarrow.tsx b/src/components/SelectionList/Search/ExpenseItemHeaderNarrow.tsx deleted file mode 100644 index 8175c05c619b..000000000000 --- a/src/components/SelectionList/Search/ExpenseItemHeaderNarrow.tsx +++ /dev/null @@ -1,106 +0,0 @@ -import React, {memo, useMemo} from 'react'; -import {View} from 'react-native'; -import type {StyleProp, ViewStyle} from 'react-native'; -import {getButtonRole} from '@components/Button/utils'; -import Icon from '@components/Icon'; -import * as Expensicons from '@components/Icon/Expensicons'; -import {PressableWithFeedback} from '@components/Pressable'; -import useStyleUtils from '@hooks/useStyleUtils'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; -import {isCorrectSearchUserName} from '@libs/SearchUIUtils'; -import CONST from '@src/CONST'; -import type {SearchPersonalDetails, SearchTransactionAction} from '@src/types/onyx/SearchResults'; -import ActionCell from './ActionCell'; -import UserInfoCellsWithArrow from './UserInfoCellsWithArrow'; - -type ExpenseItemHeaderNarrowProps = { - text?: string; - participantFrom: SearchPersonalDetails; - participantTo: SearchPersonalDetails; - participantFromDisplayName: string; - participantToDisplayName: string; - action?: SearchTransactionAction; - containerStyle?: StyleProp; - onButtonPress: () => void; - canSelectMultiple?: boolean; - isSelected?: boolean; - isDisabled?: boolean | null; - isDisabledCheckbox?: boolean; - handleCheckboxPress?: () => void; - isLoading?: boolean; -}; - -function ExpenseItemHeaderNarrow({ - participantFrom, - participantFromDisplayName, - participantTo, - participantToDisplayName, - onButtonPress, - action, - canSelectMultiple, - containerStyle, - isDisabledCheckbox, - isSelected, - isDisabled, - handleCheckboxPress, - text, - isLoading = false, -}: ExpenseItemHeaderNarrowProps) { - const styles = useThemeStyles(); - const StyleUtils = useStyleUtils(); - const theme = useTheme(); - - // It might happen that we are missing display names for `From` or `To`, we only display arrow icon if both names exist - const shouldShowToRecipient = isCorrectSearchUserName(participantFromDisplayName) && isCorrectSearchUserName(participantToDisplayName) && !!participantTo?.accountID; - const shouldShowAction = useMemo(() => action !== CONST.SEARCH.ACTION_TYPES.VIEW && action !== CONST.SEARCH.ACTION_TYPES.REVIEW, [action]); - return ( - - - {!!canSelectMultiple && ( - handleCheckboxPress?.()} - style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), isDisabledCheckbox && styles.cursorDisabled, styles.mr1]} - > - - {!!isSelected && ( - - )} - - - )} - - - - - {shouldShowAction && ( - - - - )} - - ); -} - -export default memo(ExpenseItemHeaderNarrow); From d573e3d88af2010fb7c94379051ae2a42a474090 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 2 Jun 2025 15:37:00 +0200 Subject: [PATCH 11/21] fix PR comments --- .../BaseHTMLEngineProvider.tsx | 8 ++++- .../HTMLRenderers/RBRRenderer.tsx | 7 +++-- src/components/Search/index.tsx | 30 ++++++++++++++----- .../SelectionList/Search/ReportListItem.tsx | 6 ++-- .../Search/ReportListItemHeader.tsx | 2 +- .../Search/TransactionListItem.tsx | 4 +-- .../Search/UserInfoAndActionButtonRow.tsx | 2 +- .../SelectionList/SearchTableHeader.tsx | 5 ---- src/components/SelectionList/types.ts | 5 ++++ .../TransactionItemRowRBR.tsx | 8 +++-- src/components/TransactionItemRow/index.tsx | 8 +++-- 11 files changed, 56 insertions(+), 29 deletions(-) diff --git a/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.tsx b/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.tsx index ef4a472feeb3..f133aee5176b 100755 --- a/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.tsx +++ b/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.tsx @@ -50,7 +50,13 @@ function BaseHTMLEngineProvider({textSelectable = false, children, enableExperim }), rbr: HTMLElementModel.fromCustomModel({ tagName: 'rbr', - mixedUAStyles: {...styles.formError, ...styles.mb0}, + // mixedUAStyles: {...styles.formError, ...styles.mb0}, + getMixedUAStyles: (tnode) => { + if (tnode.attributes.issmall === undefined) { + return {...styles.formError, ...styles.mb0}; + } + return {...styles.formError, ...styles.mb0, ...styles.textMicro}; + }, contentModel: HTMLContentModel.block, }), 'muted-text': HTMLElementModel.fromCustomModel({ diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/RBRRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/RBRRenderer.tsx index 6239e930fbe0..140949289ae1 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/RBRRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/RBRRenderer.tsx @@ -1,13 +1,16 @@ import React from 'react'; +import {StyleSheet} from 'react-native'; +import type {TextStyle} from 'react-native'; import type {CustomRendererProps, TPhrasing, TText} from 'react-native-render-html'; import {TNodeChildrenRenderer} from 'react-native-render-html'; import Text from '@components/Text'; import useThemeStyles from '@hooks/useThemeStyles'; -function RBRRenderer({tnode}: CustomRendererProps) { +function RBRRenderer({tnode, style}: CustomRendererProps) { const styles = useThemeStyles(); const htmlAttribs = tnode.attributes; const shouldShowEllipsis = htmlAttribs?.shouldshowellipsis !== undefined; + const flattenStyle = StyleSheet.flatten(style as TextStyle); return ( ) { numberOfLines={shouldShowEllipsis ? 1 : 0} ellipsizeMode="tail" key={props.key} - style={[styles.textLabelError]} + style={[styles.textLabelError, flattenStyle]} > {props.childElement} diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 80bf128c4430..6c854d56a760 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -80,11 +80,23 @@ function mapTransactionItemToSelectedEntry(item: TransactionListItemType, report ]; } -function mapToTransactionItemWithSelectionInfo(item: TransactionListItemType, selectedTransactions: SelectedTransactions, canSelectMultiple: boolean, shouldAnimateInHighlight: boolean) { - return {...item, shouldAnimateInHighlight, isSelected: selectedTransactions[item.keyForList]?.isSelected && canSelectMultiple}; +function mapToTransactionItemWithAdditionalInfo( + item: TransactionListItemType, + selectedTransactions: SelectedTransactions, + canSelectMultiple: boolean, + shouldAnimateInHighlight: boolean, + shouldShowYear: boolean, +) { + return {...item, shouldAnimateInHighlight, isSelected: selectedTransactions[item.keyForList]?.isSelected && canSelectMultiple, shouldShowYear}; } -function mapToItemWithSelectionInfo(item: SearchListItem, selectedTransactions: SelectedTransactions, canSelectMultiple: boolean, shouldAnimateInHighlight: boolean) { +function mapToItemWithAdditionalInfo( + item: SearchListItem, + selectedTransactions: SelectedTransactions, + canSelectMultiple: boolean, + shouldAnimateInHighlight: boolean, + shouldShowYear: boolean, +) { if (isTaskListItemType(item)) { return { ...item, @@ -96,15 +108,19 @@ function mapToItemWithSelectionInfo(item: SearchListItem, selectedTransactions: return { ...item, shouldAnimateInHighlight, + shouldShowYear, }; } return isTransactionListItemType(item) - ? mapToTransactionItemWithSelectionInfo(item, selectedTransactions, canSelectMultiple, shouldAnimateInHighlight) + ? mapToTransactionItemWithAdditionalInfo(item, selectedTransactions, canSelectMultiple, shouldAnimateInHighlight, shouldShowYear) : { ...item, shouldAnimateInHighlight, - transactions: item.transactions?.map((transaction) => mapToTransactionItemWithSelectionInfo(transaction, selectedTransactions, canSelectMultiple, shouldAnimateInHighlight)), + shouldShowYear, + transactions: item.transactions?.map((transaction) => + mapToTransactionItemWithAdditionalInfo(transaction, selectedTransactions, canSelectMultiple, shouldAnimateInHighlight, shouldShowYear), + ), isSelected: item?.transactions?.length > 0 && item.transactions?.every((transaction) => selectedTransactions[transaction.keyForList]?.isSelected && canSelectMultiple), }; } @@ -482,6 +498,7 @@ function Search({queryJSON, currentSearchResults, lastNonEmptySearchResults, onS const isChat = type === CONST.SEARCH.DATA_TYPES.CHAT; const isTask = type === CONST.SEARCH.DATA_TYPES.TASK; const canSelectMultiple = !isChat && !isTask && (!isSmallScreenWidth || selectionMode?.isEnabled === true); + const shouldShowYear = shouldShowYearUtil(searchResults?.data); const sortedSelectedData = sortedData.map((item) => { const baseKey = isChat @@ -499,7 +516,7 @@ function Search({queryJSON, currentSearchResults, lastNonEmptySearchResults, onS // Determine if either the base key or any transaction key matches const shouldAnimateInHighlight = isBaseKeyMatch || isAnyTransactionMatch; - return mapToItemWithSelectionInfo(item, selectedTransactions, canSelectMultiple, shouldAnimateInHighlight); + return mapToItemWithAdditionalInfo(item, selectedTransactions, canSelectMultiple, shouldAnimateInHighlight, shouldShowYear); }); const hasErrors = Object.keys(searchResults?.errors ?? {}).length > 0 && !isOffline; @@ -568,7 +585,6 @@ function Search({queryJSON, currentSearchResults, lastNonEmptySearchResults, onS navigation.setParams({q: newQuery}); }; - const shouldShowYear = shouldShowYearUtil(searchResults?.data); const shouldShowSorting = !Array.isArray(status) && !shouldGroupByReports; const shouldShowTableHeader = isLargeScreenWidth && !isChat; diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index 967198281417..f7e8a32e104a 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -13,7 +13,6 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; -import shouldShowTransactionYear from '@libs/TransactionUtils/shouldShowTransactionYear'; import variables from '@styles/variables'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -44,9 +43,8 @@ function ReportListItem({ const {isLargeScreenWidth} = useResponsiveLayout(); const dateColumnSize = useMemo(() => { - const shouldShowYearForSomeTransaction = reportItem.transactions.some((transaction) => shouldShowTransactionYear(transaction)); - return shouldShowYearForSomeTransaction ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL; - }, [reportItem.transactions]); + return reportItem?.shouldShowYear ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL; + }, [reportItem?.shouldShowYear]); const animatedHighlightStyle = useAnimatedHighlightStyle({ borderRadius: variables.componentBorderRadius, diff --git a/src/components/SelectionList/Search/ReportListItemHeader.tsx b/src/components/SelectionList/Search/ReportListItemHeader.tsx index b441ed7ec25e..f6ceb1da9caa 100644 --- a/src/components/SelectionList/Search/ReportListItemHeader.tsx +++ b/src/components/SelectionList/Search/ReportListItemHeader.tsx @@ -121,7 +121,7 @@ function FirstHeaderRow({ style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), reportItem.isDisabledCheckbox && styles.cursorDisabled]} /> )} - + ({ }); const dateColumnSize = useMemo(() => { - const shouldShowYearForSomeTransaction = shouldShowTransactionYear(transactionItem); - return shouldShowYearForSomeTransaction ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL; + return transactionItem.shouldShowYear ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL; }, [transactionItem]); const columns = useMemo( diff --git a/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx b/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx index fe7334285cde..33af24934255 100644 --- a/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx +++ b/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx @@ -41,7 +41,7 @@ function UserInfoAndActionButtonRow({ /> )} - + true, [CONST.SEARCH.TABLE_COLUMNS.ASSIGNEE]: () => true, [CONST.SEARCH.TABLE_COLUMNS.IN]: () => true, - // This column is never displayed on Search - [CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: () => false, }; const expenseHeaders: SearchColumnConfig[] = [ @@ -179,9 +177,6 @@ function SearchTableHeader({data, metadata, sortBy, sortOrder, onSortPress, shou // Don't butt up against the 'select all' checkbox if present containerStyles={canSelectMultiple && [styles.pl4]} onSortPress={(columnName, order) => { - if (columnName === CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS) { - return; - } onSortPress(columnName, order); }} /> diff --git a/src/components/SelectionList/types.ts b/src/components/SelectionList/types.ts index 4157edc720a9..778b76be51a3 100644 --- a/src/components/SelectionList/types.ts +++ b/src/components/SelectionList/types.ts @@ -319,6 +319,11 @@ type ReportListItemType = ListItem & /** List of transactions that belong to this report */ transactions: TransactionListItemType[]; + + /** Whether we should show the transaction year. + * This is true if at least one transaction in the dataset was created in past years + */ + shouldShowYear?: boolean; }; type ListItemProps = CommonListItemProps & { diff --git a/src/components/TransactionItemRow/TransactionItemRowRBR.tsx b/src/components/TransactionItemRow/TransactionItemRowRBR.tsx index ae493d5ebe33..1639ad9f46c2 100644 --- a/src/components/TransactionItemRow/TransactionItemRowRBR.tsx +++ b/src/components/TransactionItemRow/TransactionItemRowRBR.tsx @@ -25,6 +25,8 @@ type TransactionItemRowRBRProps = { /** Styles for the RBR messages container */ containerStyles?: ViewStyle[]; + + shouldUseNarrowLayout: boolean; }; /** @@ -64,7 +66,7 @@ const extractErrorMessages = (errors: Errors | ReceiptErrors, errorActions: Repo return Array.from(uniqueMessages); }; -function TransactionItemRowRBR({transaction, containerStyles}: TransactionItemRowRBRProps) { +function TransactionItemRowRBR({transaction, containerStyles, shouldUseNarrowLayout}: TransactionItemRowRBRProps) { const styles = useThemeStyles(); const transactionViolations = useTransactionViolations(transaction?.transactionID); const {translate} = useLocalize(); @@ -99,8 +101,8 @@ function TransactionItemRowRBR({transaction, containerStyles}: TransactionItemRo height={variables.iconSizeExtraSmall} width={variables.iconSizeExtraSmall} /> - - ${RBRMessages}`} /> + + ${RBRMessages}`} /> ) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index bb897b573a50..03f11fd7437d 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -283,7 +283,7 @@ function TransactionItemRow({ {shouldUseNarrowLayout ? ( - + {shouldShowCheckbox && ( @@ -361,6 +361,7 @@ function TransactionItemRow({ {columns?.map((column) => columnComponent[column])} - + )} From 69fd38744cb6553960478f9ccf25378edb8f18ba Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 2 Jun 2025 16:13:00 +0200 Subject: [PATCH 12/21] fix linter --- .../HTMLEngineProvider/BaseHTMLEngineProvider.tsx | 9 +++++---- src/components/SelectionList/SearchTableHeader.tsx | 5 +++++ src/components/SelectionList/types.ts | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.tsx b/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.tsx index f133aee5176b..92ed47698149 100755 --- a/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.tsx +++ b/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.tsx @@ -140,22 +140,23 @@ function BaseHTMLEngineProvider({textSelectable = false, children, enableExperim }), }), [ + styles.taskTitleMenuItem, styles.formError, styles.mb0, styles.colorMuted, + styles.mutedNormalTextLabel, styles.textLabelSupporting, styles.lh16, styles.textSupporting, styles.textLineThrough, - styles.mutedNormalTextLabel, + styles.textMicro, styles.onlyEmojisText, - styles.onlyEmojisTextLineHeight, - styles.taskTitleMenuItem, + styles.strong, styles.taskTitleMenuItemItalic, styles.em, - styles.strong, styles.h1, styles.blockquote, + styles.onlyEmojisTextLineHeight, ], ); /* eslint-enable @typescript-eslint/naming-convention */ diff --git a/src/components/SelectionList/SearchTableHeader.tsx b/src/components/SelectionList/SearchTableHeader.tsx index 4fb8598f3f7a..5d655991fa15 100644 --- a/src/components/SelectionList/SearchTableHeader.tsx +++ b/src/components/SelectionList/SearchTableHeader.tsx @@ -33,6 +33,8 @@ const shouldShowColumnConfig: Record true, [CONST.SEARCH.TABLE_COLUMNS.ASSIGNEE]: () => true, [CONST.SEARCH.TABLE_COLUMNS.IN]: () => true, + // This column is never displayed on Search + [CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS]: () => false, }; const expenseHeaders: SearchColumnConfig[] = [ @@ -177,6 +179,9 @@ function SearchTableHeader({data, metadata, sortBy, sortOrder, onSortPress, shou // Don't butt up against the 'select all' checkbox if present containerStyles={canSelectMultiple && [styles.pl4]} onSortPress={(columnName, order) => { + if (columnName === CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS) { + return; + } onSortPress(columnName, order); }} /> diff --git a/src/components/SelectionList/types.ts b/src/components/SelectionList/types.ts index 778b76be51a3..98693b5becc3 100644 --- a/src/components/SelectionList/types.ts +++ b/src/components/SelectionList/types.ts @@ -829,7 +829,7 @@ type ExtendedSectionListData = ExtendedSectionListData>; -type SortableColumnName = SearchColumnType; +type SortableColumnName = SearchColumnType | typeof CONST.REPORT.TRANSACTION_LIST.COLUMNS.COMMENTS; type SearchListItem = TransactionListItemType | ReportListItemType | ReportActionListItemType | TaskListItemType; From aa4bbd784297d2cd2946dc05951c6900a91d5fec Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 2 Jun 2025 16:17:25 +0200 Subject: [PATCH 13/21] revert old prettier changes --- src/CONST.ts | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index c6245a2e9c23..8eac62a893da 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3631,11 +3631,14 @@ const CONST = { SELF_SELECT: '__predefined_selfSelect', }, - EXPENSIFY_EMAILS_OBJECT: Object.entries(EMAIL).reduce((prev, [, email]) => { - // eslint-disable-next-line no-param-reassign - prev[email] = true; - return prev; - }, {} as Record), + EXPENSIFY_EMAILS_OBJECT: Object.entries(EMAIL).reduce( + (prev, [, email]) => { + // eslint-disable-next-line no-param-reassign + prev[email] = true; + return prev; + }, + {} as Record, + ), EXPENSIFY_EMAILS: [ EMAIL.ACCOUNTING, EMAIL.ACCOUNTS_PAYABLE, @@ -5495,15 +5498,9 @@ const CONST = { type: 'addAccountingIntegration', autoCompleted: false, mediaAttributes: { - [`${CLOUDFRONT_URL}/${ - connectionsVideoPaths[ONBOARDING_ACCOUNTING_MAPPING.netsuite] - }`]: `data-expensify-thumbnail-url="${CLOUDFRONT_URL}/images/walkthrough-connect_to_netsuite.png" data-expensify-width="1920" data-expensify-height="1080"`, - [`${CLOUDFRONT_URL}/${ - connectionsVideoPaths[ONBOARDING_ACCOUNTING_MAPPING.quickbooksOnline] - }`]: `data-expensify-thumbnail-url="${CLOUDFRONT_URL}/images/walkthrough-connect_to_qbo.png" data-expensify-width="1920" data-expensify-height="1080"`, - [`${CLOUDFRONT_URL}/${ - connectionsVideoPaths[ONBOARDING_ACCOUNTING_MAPPING.xero] - }`]: `data-expensify-thumbnail-url="${CLOUDFRONT_URL}/images/walkthrough-connect_to_xero.png" data-expensify-width="1920" data-expensify-height="1080"`, + [`${CLOUDFRONT_URL}/${connectionsVideoPaths[ONBOARDING_ACCOUNTING_MAPPING.netsuite]}`]: `data-expensify-thumbnail-url="${CLOUDFRONT_URL}/images/walkthrough-connect_to_netsuite.png" data-expensify-width="1920" data-expensify-height="1080"`, + [`${CLOUDFRONT_URL}/${connectionsVideoPaths[ONBOARDING_ACCOUNTING_MAPPING.quickbooksOnline]}`]: `data-expensify-thumbnail-url="${CLOUDFRONT_URL}/images/walkthrough-connect_to_qbo.png" data-expensify-width="1920" data-expensify-height="1080"`, + [`${CLOUDFRONT_URL}/${connectionsVideoPaths[ONBOARDING_ACCOUNTING_MAPPING.xero]}`]: `data-expensify-thumbnail-url="${CLOUDFRONT_URL}/images/walkthrough-connect_to_xero.png" data-expensify-width="1920" data-expensify-height="1080"`, }, title: ({integrationName, workspaceAccountingLink}) => `Connect to [${integrationName}](${workspaceAccountingLink})`, description: ({integrationName, workspaceAccountingLink}) => From bcdfa6fe5dc5c5d9bdeb23827b351bafe326e62f Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 2 Jun 2025 16:25:57 +0200 Subject: [PATCH 14/21] make TransactionItemRowRBR use small font on all window sizes --- src/components/TransactionItemRow/TransactionItemRowRBR.tsx | 6 ++---- src/components/TransactionItemRow/index.tsx | 6 +----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/components/TransactionItemRow/TransactionItemRowRBR.tsx b/src/components/TransactionItemRow/TransactionItemRowRBR.tsx index 1639ad9f46c2..55c9c4c90a24 100644 --- a/src/components/TransactionItemRow/TransactionItemRowRBR.tsx +++ b/src/components/TransactionItemRow/TransactionItemRowRBR.tsx @@ -25,8 +25,6 @@ type TransactionItemRowRBRProps = { /** Styles for the RBR messages container */ containerStyles?: ViewStyle[]; - - shouldUseNarrowLayout: boolean; }; /** @@ -66,7 +64,7 @@ const extractErrorMessages = (errors: Errors | ReceiptErrors, errorActions: Repo return Array.from(uniqueMessages); }; -function TransactionItemRowRBR({transaction, containerStyles, shouldUseNarrowLayout}: TransactionItemRowRBRProps) { +function TransactionItemRowRBR({transaction, containerStyles}: TransactionItemRowRBRProps) { const styles = useThemeStyles(); const transactionViolations = useTransactionViolations(transaction?.transactionID); const {translate} = useLocalize(); @@ -102,7 +100,7 @@ function TransactionItemRowRBR({transaction, containerStyles, shouldUseNarrowLay width={variables.iconSizeExtraSmall} /> - ${RBRMessages}`} /> + ${RBRMessages}`} /> ) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 03f11fd7437d..a493560220fb 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -361,7 +361,6 @@ function TransactionItemRow({ {columns?.map((column) => columnComponent[column])} - + )} From 5cca57924429155894fe591535a66d03ed510911 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Tue, 3 Jun 2025 13:05:04 +0200 Subject: [PATCH 15/21] fix wrong from column --- src/components/TransactionItemRow/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index a493560220fb..fa72c4c016ba 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -230,7 +230,7 @@ function TransactionItemRow({ )} From be50743dc180d436879d7a84b89afb2ceaafbc0d Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Tue, 3 Jun 2025 13:27:30 +0200 Subject: [PATCH 16/21] fix TransactionItemRow category and RBR heights --- src/components/TransactionItemRow/index.tsx | 8 ++++---- src/styles/utils/spacing.ts | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index fa72c4c016ba..0aca5e879285 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -342,10 +342,10 @@ function TransactionItemRow({ )} - + {hasCategoryOrTag && ( - + diff --git a/src/styles/utils/spacing.ts b/src/styles/utils/spacing.ts index 47c4f733a472..c1bfcbac5095 100644 --- a/src/styles/utils/spacing.ts +++ b/src/styles/utils/spacing.ts @@ -759,6 +759,10 @@ export default { columnGap: 12, }, + minHeight4: { + minHeight: 16, + }, + minHeight5: { minHeight: 20, }, From df7a7bab2a9fb07275ff21541570b3c9f64ce5cf Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Tue, 3 Jun 2025 16:39:08 +0200 Subject: [PATCH 17/21] fix PR comments --- .../BaseHTMLEngineProvider.tsx | 1 - src/components/Search/index.tsx | 30 +++---------- .../SelectionList/Search/ReportListItem.tsx | 7 +-- .../Search/ReportListItemHeader.tsx | 6 +-- .../Search/TransactionListItem.tsx | 3 +- .../Search/UserInfoAndActionButtonRow.tsx | 15 ++++--- src/components/SelectionList/types.ts | 11 ----- .../DataCells/MerchantCell.tsx | 24 ----------- src/components/TransactionItemRow/index.tsx | 43 ++++++++++++++++--- 9 files changed, 60 insertions(+), 80 deletions(-) diff --git a/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.tsx b/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.tsx index 92ed47698149..487ff440279a 100755 --- a/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.tsx +++ b/src/components/HTMLEngineProvider/BaseHTMLEngineProvider.tsx @@ -50,7 +50,6 @@ function BaseHTMLEngineProvider({textSelectable = false, children, enableExperim }), rbr: HTMLElementModel.fromCustomModel({ tagName: 'rbr', - // mixedUAStyles: {...styles.formError, ...styles.mb0}, getMixedUAStyles: (tnode) => { if (tnode.attributes.issmall === undefined) { return {...styles.formError, ...styles.mb0}; diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 6c854d56a760..5589d70769dc 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -80,23 +80,11 @@ function mapTransactionItemToSelectedEntry(item: TransactionListItemType, report ]; } -function mapToTransactionItemWithAdditionalInfo( - item: TransactionListItemType, - selectedTransactions: SelectedTransactions, - canSelectMultiple: boolean, - shouldAnimateInHighlight: boolean, - shouldShowYear: boolean, -) { - return {...item, shouldAnimateInHighlight, isSelected: selectedTransactions[item.keyForList]?.isSelected && canSelectMultiple, shouldShowYear}; +function mapToTransactionItemWithAdditionalInfo(item: TransactionListItemType, selectedTransactions: SelectedTransactions, canSelectMultiple: boolean, shouldAnimateInHighlight: boolean) { + return {...item, shouldAnimateInHighlight, isSelected: selectedTransactions[item.keyForList]?.isSelected && canSelectMultiple}; } -function mapToItemWithAdditionalInfo( - item: SearchListItem, - selectedTransactions: SelectedTransactions, - canSelectMultiple: boolean, - shouldAnimateInHighlight: boolean, - shouldShowYear: boolean, -) { +function mapToItemWithAdditionalInfo(item: SearchListItem, selectedTransactions: SelectedTransactions, canSelectMultiple: boolean, shouldAnimateInHighlight: boolean) { if (isTaskListItemType(item)) { return { ...item, @@ -108,19 +96,15 @@ function mapToItemWithAdditionalInfo( return { ...item, shouldAnimateInHighlight, - shouldShowYear, }; } return isTransactionListItemType(item) - ? mapToTransactionItemWithAdditionalInfo(item, selectedTransactions, canSelectMultiple, shouldAnimateInHighlight, shouldShowYear) + ? mapToTransactionItemWithAdditionalInfo(item, selectedTransactions, canSelectMultiple, shouldAnimateInHighlight) : { ...item, shouldAnimateInHighlight, - shouldShowYear, - transactions: item.transactions?.map((transaction) => - mapToTransactionItemWithAdditionalInfo(transaction, selectedTransactions, canSelectMultiple, shouldAnimateInHighlight, shouldShowYear), - ), + transactions: item.transactions?.map((transaction) => mapToTransactionItemWithAdditionalInfo(transaction, selectedTransactions, canSelectMultiple, shouldAnimateInHighlight)), isSelected: item?.transactions?.length > 0 && item.transactions?.every((transaction) => selectedTransactions[transaction.keyForList]?.isSelected && canSelectMultiple), }; } @@ -498,7 +482,6 @@ function Search({queryJSON, currentSearchResults, lastNonEmptySearchResults, onS const isChat = type === CONST.SEARCH.DATA_TYPES.CHAT; const isTask = type === CONST.SEARCH.DATA_TYPES.TASK; const canSelectMultiple = !isChat && !isTask && (!isSmallScreenWidth || selectionMode?.isEnabled === true); - const shouldShowYear = shouldShowYearUtil(searchResults?.data); const sortedSelectedData = sortedData.map((item) => { const baseKey = isChat @@ -516,7 +499,7 @@ function Search({queryJSON, currentSearchResults, lastNonEmptySearchResults, onS // Determine if either the base key or any transaction key matches const shouldAnimateInHighlight = isBaseKeyMatch || isAnyTransactionMatch; - return mapToItemWithAdditionalInfo(item, selectedTransactions, canSelectMultiple, shouldAnimateInHighlight, shouldShowYear); + return mapToItemWithAdditionalInfo(item, selectedTransactions, canSelectMultiple, shouldAnimateInHighlight); }); const hasErrors = Object.keys(searchResults?.errors ?? {}).length > 0 && !isOffline; @@ -585,6 +568,7 @@ function Search({queryJSON, currentSearchResults, lastNonEmptySearchResults, onS navigation.setParams({q: newQuery}); }; + const shouldShowYear = shouldShowYearUtil(searchResults?.data); const shouldShowSorting = !Array.isArray(status) && !shouldGroupByReports; const shouldShowTableHeader = isLargeScreenWidth && !isChat; diff --git a/src/components/SelectionList/Search/ReportListItem.tsx b/src/components/SelectionList/Search/ReportListItem.tsx index f7e8a32e104a..c6271489ebca 100644 --- a/src/components/SelectionList/Search/ReportListItem.tsx +++ b/src/components/SelectionList/Search/ReportListItem.tsx @@ -43,8 +43,8 @@ function ReportListItem({ const {isLargeScreenWidth} = useResponsiveLayout(); const dateColumnSize = useMemo(() => { - return reportItem?.shouldShowYear ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL; - }, [reportItem?.shouldShowYear]); + return reportItem.transactions.some((transaction) => transaction.shouldShowYear) ? CONST.SEARCH.TABLE_COLUMN_SIZES.WIDE : CONST.SEARCH.TABLE_COLUMN_SIZES.NORMAL; + }, [reportItem.transactions]); const animatedHighlightStyle = useAnimatedHighlightStyle({ borderRadius: variables.componentBorderRadius, @@ -100,7 +100,7 @@ function ReportListItem({ ...(sampleTransaction?.shouldShowTax ? [COLUMNS.TAX] : []), COLUMNS.TOTAL_AMOUNT, COLUMNS.ACTION, - ] as Array>; + ] satisfies Array>; return ( ({ }} isParentHovered={hovered} columnWrapperStyles={[styles.ph3, styles.pv1half]} + isReportItemChild /> )) diff --git a/src/components/SelectionList/Search/ReportListItemHeader.tsx b/src/components/SelectionList/Search/ReportListItemHeader.tsx index f6ceb1da9caa..1c534ce49c93 100644 --- a/src/components/SelectionList/Search/ReportListItemHeader.tsx +++ b/src/components/SelectionList/Search/ReportListItemHeader.tsx @@ -94,7 +94,7 @@ function TotalCell({showTooltip, isLargeScreenWidth, reportItem}: ReportCellProp ); } -function FirstHeaderRow({ +function HeaderFirstRow({ policy, report: reportItem, onCheckboxPress, @@ -179,7 +179,7 @@ function ReportListItemHeader({ }; return !isLargeScreenWidth ? ( - ({ ) : ( - ({ ...(transactionItem?.shouldShowTax ? [CONST.REPORT.TRANSACTION_LIST.COLUMNS.TAX] : []), CONST.REPORT.TRANSACTION_LIST.COLUMNS.TOTAL_AMOUNT, CONST.REPORT.TRANSACTION_LIST.COLUMNS.ACTION, - ] as Array>, + ] satisfies Array>, [transactionItem?.shouldShowCategory, transactionItem?.shouldShowTag, transactionItem?.shouldShowTax], ); @@ -123,7 +123,6 @@ function TransactionListItem({ isSelected={!!transactionItem.isSelected} dateColumnSize={dateColumnSize} shouldShowCheckbox={!!canSelectMultiple} - isChildListItem={false} /> )} diff --git a/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx b/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx index 33af24934255..a440b3491771 100644 --- a/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx +++ b/src/components/SelectionList/Search/UserInfoAndActionButtonRow.tsx @@ -4,6 +4,8 @@ import type {ReportListItemType, TransactionListItemType} from '@components/Sele import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {isCorrectSearchUserName} from '@libs/SearchUIUtils'; +import variables from '@styles/variables'; +import CONST from '@src/CONST'; import ActionCell from './ActionCell'; import UserInfoCellsWithArrow from './UserInfoCellsWithArrow'; @@ -19,10 +21,11 @@ function UserInfoAndActionButtonRow({ const {translate} = useLocalize(); const styles = useThemeStyles(); const hasFromSender = !!item?.from && !!item?.from?.accountID && !!item?.from?.displayName; - const hasToRecipent = !!item?.to && !!item?.to?.accountID && !!item?.to?.displayName; + const hasToRecipient = !!item?.to && !!item?.to?.accountID && !!item?.to?.displayName; + const participantFromDisplayName = item?.from?.displayName ?? item?.from?.login ?? translate('common.hidden'); const participantToDisplayName = item?.to?.displayName ?? item?.to?.login ?? translate('common.hidden'); const shouldShowToRecipient = - hasFromSender && hasToRecipent && !!item?.to?.accountID && item?.from?.accountID !== item?.to?.accountID && !!isCorrectSearchUserName(participantToDisplayName); + hasFromSender && hasToRecipient && !!item?.to?.accountID && item?.from?.accountID !== item?.to?.accountID && !!isCorrectSearchUserName(participantToDisplayName); return ( @@ -31,17 +34,17 @@ function UserInfoAndActionButtonRow({ )} - + = CommonListItemProps & { diff --git a/src/components/TransactionItemRow/DataCells/MerchantCell.tsx b/src/components/TransactionItemRow/DataCells/MerchantCell.tsx index 6b33cf90c2e8..a0db1aa25e7f 100644 --- a/src/components/TransactionItemRow/DataCells/MerchantCell.tsx +++ b/src/components/TransactionItemRow/DataCells/MerchantCell.tsx @@ -1,29 +1,6 @@ import React from 'react'; import TextWithTooltip from '@components/TextWithTooltip'; import useThemeStyles from '@hooks/useThemeStyles'; -import Parser from '@libs/Parser'; -import StringUtils from '@libs/StringUtils'; -import {getDescription, getMerchant, hasReceipt, isReceiptBeingScanned} from '@libs/TransactionUtils'; -import CONST from '@src/CONST'; -import type {TranslationPaths} from '@src/languages/types'; -import type {TransactionWithOptionalSearchFields} from '..'; - -/** If merchant name is empty or (none), then it it falls back to description if screen is narrow */ -function getMerchantNameWithFallback(transactionItem: TransactionWithOptionalSearchFields, translate: (key: TranslationPaths) => string, shouldUseNarrowLayout?: boolean | undefined) { - const shouldShowMerchant = transactionItem.shouldShowMerchant ?? true; - const description = getDescription(transactionItem); - let merchantOrDescriptionToDisplay = transactionItem?.formattedMerchant ?? getMerchant(transactionItem); - if ((!merchantOrDescriptionToDisplay || merchantOrDescriptionToDisplay === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT) && shouldUseNarrowLayout) { - merchantOrDescriptionToDisplay = Parser.htmlToText(description); - } - let merchant = shouldShowMerchant ? merchantOrDescriptionToDisplay : Parser.htmlToText(description); - - if (hasReceipt(transactionItem) && isReceiptBeingScanned(transactionItem) && shouldShowMerchant) { - merchant = translate('iou.receiptStatusTitle'); - } - const merchantName = StringUtils.getFirstLine(merchant); - return merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT ? merchantName : ''; -} function MerchantOrDescriptionCell({ merchantOrDescription, @@ -47,4 +24,3 @@ function MerchantOrDescriptionCell({ MerchantOrDescriptionCell.displayName = 'MerchantOrDescriptionCell'; export default MerchantOrDescriptionCell; -export {getMerchantNameWithFallback}; diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index 0aca5e879285..fac5168e1712 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -17,13 +17,24 @@ import useLocalize from '@hooks/useLocalize'; import useStyleUtils from '@hooks/useStyleUtils'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import {getCreated as getTransactionCreated, getTransactionPendingAction, isTransactionPendingDelete} from '@libs/TransactionUtils'; +import Parser from '@libs/Parser'; +import StringUtils from '@libs/StringUtils'; +import { + getDescription, + getMerchant, + getCreated as getTransactionCreated, + getTransactionPendingAction, + hasReceipt, + isReceiptBeingScanned, + isTransactionPendingDelete, +} from '@libs/TransactionUtils'; import variables from '@styles/variables'; import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; import type {SearchPersonalDetails, SearchTransactionAction} from '@src/types/onyx/SearchResults'; import CategoryCell from './DataCells/CategoryCell'; import ChatBubbleCell from './DataCells/ChatBubbleCell'; -import MerchantOrDescriptionCell, {getMerchantNameWithFallback} from './DataCells/MerchantCell'; +import MerchantOrDescriptionCell from './DataCells/MerchantCell'; import ReceiptCell from './DataCells/ReceiptCell'; import TagCell from './DataCells/TagCell'; import TaxCell from './DataCells/TaxCell'; @@ -77,11 +88,29 @@ type TransactionItemRowProps = { isParentHovered?: boolean; columnWrapperStyles?: ViewStyle[]; scrollToNewTransaction?: ((offset: number) => void) | undefined; - isChildListItem?: boolean; + isReportItemChild?: boolean; isActionLoading?: boolean; shouldUseAnimatedHighlight?: boolean; }; +/** If merchant name is empty or (none), then it falls back to description if screen is narrow */ +function getMerchantNameWithFallback(transactionItem: TransactionWithOptionalSearchFields, translate: (key: TranslationPaths) => string, shouldUseNarrowLayout?: boolean | undefined) { + const shouldShowMerchant = transactionItem.shouldShowMerchant ?? true; + const description = getDescription(transactionItem); + let merchantOrDescriptionToDisplay = transactionItem?.formattedMerchant ?? getMerchant(transactionItem); + const merchantNameEmpty = !merchantOrDescriptionToDisplay || merchantOrDescriptionToDisplay === CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT; + if (merchantNameEmpty && shouldUseNarrowLayout) { + merchantOrDescriptionToDisplay = Parser.htmlToText(description); + } + let merchant = shouldShowMerchant ? merchantOrDescriptionToDisplay : Parser.htmlToText(description); + + if (hasReceipt(transactionItem) && isReceiptBeingScanned(transactionItem) && shouldShowMerchant) { + merchant = translate('iou.receiptStatusTitle'); + } + const merchantName = StringUtils.getFirstLine(merchant); + return merchant !== CONST.TRANSACTION.PARTIAL_TRANSACTION_MERCHANT ? merchantName : ''; +} + function TransactionItemRow({ transactionItem, shouldUseNarrowLayout, @@ -95,7 +124,7 @@ function TransactionItemRow({ isParentHovered, columnWrapperStyles, scrollToNewTransaction, - isChildListItem = true, + isReportItemChild = false, isActionLoading, shouldUseAnimatedHighlight = false, }: TransactionItemRowProps) { @@ -130,7 +159,7 @@ function TransactionItemRow({ } }, [hovered, isParentHovered, isSelected, styles.activeComponentBG, styles.hoveredComponentBG]); - const merchantOrDescriptionName = getMerchantNameWithFallback(transactionItem, translate, shouldUseNarrowLayout); + const merchantOrDescriptionName = useMemo(() => getMerchantNameWithFallback(transactionItem, translate, shouldUseNarrowLayout), [shouldUseNarrowLayout, transactionItem, translate]); useEffect(() => { if (!transactionItem.shouldBeHighlighted || !scrollToNewTransaction) { @@ -194,7 +223,7 @@ function TransactionItemRow({ Date: Tue, 3 Jun 2025 18:21:47 +0200 Subject: [PATCH 18/21] make TransactionItemRow accept passed transaction --- .../MoneyRequestReportTransactionList.tsx | 2 +- src/components/SelectionList/types.ts | 11 +- .../TransactionItemRowRBR.tsx | 72 ++---------- .../TransactionItemRowRBRWithOnyx.tsx | 111 ++++++++++++++++++ src/components/TransactionItemRow/index.tsx | 22 +++- src/libs/SearchUIUtils.ts | 51 +++++--- 6 files changed, 184 insertions(+), 85 deletions(-) create mode 100644 src/components/TransactionItemRow/TransactionItemRowRBRWithOnyx.tsx diff --git a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx index 612c1d7beea5..9f2e4e43723c 100644 --- a/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx +++ b/src/components/MoneyRequestReportView/MoneyRequestReportTransactionList.tsx @@ -285,7 +285,7 @@ function MoneyRequestReportTransactionList({ onCheckboxPress={toggleTransaction} columns={allReportColumns} scrollToNewTransaction={transaction.transactionID === newTransactions?.at(0)?.transactionID ? scrollToNewTransaction : undefined} - shouldUseAnimatedHighlight + isInReportTableView /> ); diff --git a/src/components/SelectionList/types.ts b/src/components/SelectionList/types.ts index 62acdd3175be..5ce7a53984cb 100644 --- a/src/components/SelectionList/types.ts +++ b/src/components/SelectionList/types.ts @@ -22,7 +22,7 @@ import type SpendCategorySelectorListItem from '@pages/workspace/categories/Spen // eslint-disable-next-line no-restricted-imports import type CursorStyles from '@styles/utils/cursor/types'; import type CONST from '@src/CONST'; -import type {Policy, Report} from '@src/types/onyx'; +import type {Policy, Report, TransactionViolation} from '@src/types/onyx'; import type {Attendee, SplitExpense} from '@src/types/onyx/IOU'; import type {Errors, Icon, PendingAction} from '@src/types/onyx/OnyxCommon'; import type {SearchPersonalDetails, SearchReport, SearchReportAction, SearchTask, SearchTransaction} from '@src/types/onyx/SearchResults'; @@ -259,6 +259,9 @@ type TransactionListItemType = ListItem & /** Attendees in the transaction */ attendees?: Attendee[]; + + /** Precomputed violations */ + violations?: TransactionViolation[]; }; type ReportActionListItemType = ListItem & @@ -301,6 +304,12 @@ type TaskListItemType = ListItem & /** Key used internally by React */ keyForList: string; + + /** + * Whether we should show the task year. + * This is true if at least one task in the dataset was created in past years + */ + shouldShowYear: boolean; }; type ReportListItemType = ListItem & diff --git a/src/components/TransactionItemRow/TransactionItemRowRBR.tsx b/src/components/TransactionItemRow/TransactionItemRowRBR.tsx index 55c9c4c90a24..4849ee04d864 100644 --- a/src/components/TransactionItemRow/TransactionItemRowRBR.tsx +++ b/src/components/TransactionItemRow/TransactionItemRowRBR.tsx @@ -1,88 +1,35 @@ -import React, {useCallback} from 'react'; +import React from 'react'; import type {ViewStyle} from 'react-native'; import {View} from 'react-native'; import Icon from '@components/Icon'; import {DotIndicator} from '@components/Icon/Expensicons'; -import type {LocaleContextProps} from '@components/LocaleContextProvider'; import RenderHTML from '@components/RenderHTML'; import useLocalize from '@hooks/useLocalize'; -import usePaginatedReportActions from '@hooks/usePaginatedReportActions'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; -import useTransactionViolations from '@hooks/useTransactionViolations'; -import {isReceiptError} from '@libs/ErrorUtils'; -import {getIOUActionForTransactionID} from '@libs/ReportActionsUtils'; import ViolationsUtils from '@libs/Violations/ViolationsUtils'; import variables from '@styles/variables'; -import type {Errors} from '@src/types/onyx/OnyxCommon'; -import type ReportAction from '@src/types/onyx/ReportAction'; -import type Transaction from '@src/types/onyx/Transaction'; -import type {ReceiptError, ReceiptErrors} from '@src/types/onyx/Transaction'; +import type {TransactionViolations} from '@src/types/onyx'; type TransactionItemRowRBRProps = { /** Transaction item */ - transaction: Transaction; + transactionViolations?: TransactionViolations; /** Styles for the RBR messages container */ containerStyles?: ViewStyle[]; }; -/** - * Extracts unique error messages from errors and actions - */ -const extractErrorMessages = (errors: Errors | ReceiptErrors, errorActions: ReportAction[], translate: LocaleContextProps['translate']): string[] => { - const uniqueMessages = new Set(); - - // Combine transaction and action errors - let allErrors: Record = {...errors}; - errorActions.forEach((action) => { - if (!action.errors) { - return; - } - allErrors = {...allErrors, ...action.errors}; - }); - - // Extract error messages - Object.values(allErrors).forEach((errorValue) => { - if (!errorValue) { - return; - } - if (typeof errorValue === 'string') { - uniqueMessages.add(errorValue); - } else if (isReceiptError(errorValue)) { - uniqueMessages.add(translate('iou.error.receiptFailureMessageShort')); - } else { - Object.values(errorValue).forEach((nestedErrorValue) => { - if (!nestedErrorValue) { - return; - } - uniqueMessages.add(nestedErrorValue); - }); - } - }); - - return Array.from(uniqueMessages); -}; - -function TransactionItemRowRBR({transaction, containerStyles}: TransactionItemRowRBRProps) { +/** This component is lighter version of TransactionItemRowRBRWithOnyx that doesn't use onyx but uses transactionViolations data computed from search, + * thus it doesn't include violations taken from reportActions like its counterpart does. */ +function TransactionItemRowRBR({transactionViolations, containerStyles}: TransactionItemRowRBRProps) { const styles = useThemeStyles(); - const transactionViolations = useTransactionViolations(transaction?.transactionID); const {translate} = useLocalize(); const theme = useTheme(); - - const {sortedAllReportActions: transactionActions} = usePaginatedReportActions(transaction.reportID); - const transactionThreadId = transactionActions ? getIOUActionForTransactionID(transactionActions, transaction.transactionID)?.childReportID : undefined; - const {sortedAllReportActions: transactionThreadActions} = usePaginatedReportActions(transactionThreadId); - const getErrorMessages = useCallback( - (errors: Errors | ReceiptErrors | undefined = {}, errorActions: ReportAction[] | undefined = []) => extractErrorMessages(errors, errorActions, translate), - [translate], - ); + if (!transactionViolations) { + return null; + } const RBRMessages = [ - ...getErrorMessages( - transaction?.errors, - transactionThreadActions?.filter((e) => !!e.errors), - ), // Some violations end with a period already so lets make sure the connected messages have only single period between them // and end with a single dot. ...transactionViolations.map((violation) => { @@ -107,4 +54,5 @@ function TransactionItemRowRBR({transaction, containerStyles}: TransactionItemRo ); } +TransactionItemRowRBR.displayName = 'TransactionItemRowRBR'; export default TransactionItemRowRBR; diff --git a/src/components/TransactionItemRow/TransactionItemRowRBRWithOnyx.tsx b/src/components/TransactionItemRow/TransactionItemRowRBRWithOnyx.tsx new file mode 100644 index 000000000000..a1273181ad31 --- /dev/null +++ b/src/components/TransactionItemRow/TransactionItemRowRBRWithOnyx.tsx @@ -0,0 +1,111 @@ +import React, {useCallback} from 'react'; +import type {ViewStyle} from 'react-native'; +import {View} from 'react-native'; +import Icon from '@components/Icon'; +import {DotIndicator} from '@components/Icon/Expensicons'; +import type {LocaleContextProps} from '@components/LocaleContextProvider'; +import RenderHTML from '@components/RenderHTML'; +import useLocalize from '@hooks/useLocalize'; +import usePaginatedReportActions from '@hooks/usePaginatedReportActions'; +import useTheme from '@hooks/useTheme'; +import useThemeStyles from '@hooks/useThemeStyles'; +import useTransactionViolations from '@hooks/useTransactionViolations'; +import {isReceiptError} from '@libs/ErrorUtils'; +import {getIOUActionForTransactionID} from '@libs/ReportActionsUtils'; +import ViolationsUtils from '@libs/Violations/ViolationsUtils'; +import variables from '@styles/variables'; +import type {Errors} from '@src/types/onyx/OnyxCommon'; +import type ReportAction from '@src/types/onyx/ReportAction'; +import type Transaction from '@src/types/onyx/Transaction'; +import type {ReceiptError, ReceiptErrors} from '@src/types/onyx/Transaction'; + +type TransactionItemRowRBRProps = { + /** Transaction item */ + transaction: Transaction; + + /** Styles for the RBR messages container */ + containerStyles?: ViewStyle[]; +}; + +/** + * Extracts unique error messages from errors and actions + */ +const extractErrorMessages = (errors: Errors | ReceiptErrors, errorActions: ReportAction[], translate: LocaleContextProps['translate']): string[] => { + const uniqueMessages = new Set(); + + // Combine transaction and action errors + let allErrors: Record = {...errors}; + errorActions.forEach((action) => { + if (!action.errors) { + return; + } + allErrors = {...allErrors, ...action.errors}; + }); + + // Extract error messages + Object.values(allErrors).forEach((errorValue) => { + if (!errorValue) { + return; + } + if (typeof errorValue === 'string') { + uniqueMessages.add(errorValue); + } else if (isReceiptError(errorValue)) { + uniqueMessages.add(translate('iou.error.receiptFailureMessageShort')); + } else { + Object.values(errorValue).forEach((nestedErrorValue) => { + if (!nestedErrorValue) { + return; + } + uniqueMessages.add(nestedErrorValue); + }); + } + }); + + return Array.from(uniqueMessages); +}; + +function TransactionItemRowRBRWithOnyx({transaction, containerStyles}: TransactionItemRowRBRProps) { + const styles = useThemeStyles(); + const transactionViolations = useTransactionViolations(transaction?.transactionID); + const {translate} = useLocalize(); + const theme = useTheme(); + + const {sortedAllReportActions: transactionActions} = usePaginatedReportActions(transaction.reportID); + const transactionThreadId = transactionActions ? getIOUActionForTransactionID(transactionActions, transaction.transactionID)?.childReportID : undefined; + const {sortedAllReportActions: transactionThreadActions} = usePaginatedReportActions(transactionThreadId); + const getErrorMessages = useCallback( + (errors: Errors | ReceiptErrors | undefined = {}, errorActions: ReportAction[] | undefined = []) => extractErrorMessages(errors, errorActions, translate), + [translate], + ); + + const RBRMessages = [ + ...getErrorMessages( + transaction?.errors, + transactionThreadActions?.filter((e) => !!e.errors), + ), + // Some violations end with a period already so lets make sure the connected messages have only single period between them + // and end with a single dot. + ...transactionViolations.map((violation) => { + const message = ViolationsUtils.getViolationTranslation(violation, translate); + return message.endsWith('.') || transactionViolations.length === 1 ? message : `${message}.`; + }), + ].join(' '); + return ( + RBRMessages.length > 0 && ( + + + + ${RBRMessages}`} /> + + + ) + ); +} + +TransactionItemRowRBRWithOnyx.displayName = 'TransactionItemRowRBRWithOnyx'; +export default TransactionItemRowRBRWithOnyx; diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index fac5168e1712..f34179bd8f74 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -31,6 +31,7 @@ import { import variables from '@styles/variables'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; +import type {TransactionViolation} from '@src/types/onyx'; import type {SearchPersonalDetails, SearchTransactionAction} from '@src/types/onyx/SearchResults'; import CategoryCell from './DataCells/CategoryCell'; import ChatBubbleCell from './DataCells/ChatBubbleCell'; @@ -41,6 +42,7 @@ import TaxCell from './DataCells/TaxCell'; import TotalCell from './DataCells/TotalCell'; import TypeCell from './DataCells/TypeCell'; import TransactionItemRowRBR from './TransactionItemRowRBR'; +import TransactionItemRowRBRWithOnyx from './TransactionItemRowRBRWithOnyx'; type ColumnComponents = { [key in ValueOf]: React.ReactElement; @@ -73,6 +75,9 @@ type TransactionWithOptionalSearchFields = TransactionWithOptionalHighlight & { /** Type of transaction */ transactionType?: ValueOf; + + /** Precomputed violations */ + violations?: TransactionViolation[]; }; type TransactionItemRowProps = { @@ -90,7 +95,7 @@ type TransactionItemRowProps = { scrollToNewTransaction?: ((offset: number) => void) | undefined; isReportItemChild?: boolean; isActionLoading?: boolean; - shouldUseAnimatedHighlight?: boolean; + isInReportTableView?: boolean; }; /** If merchant name is empty or (none), then it falls back to description if screen is narrow */ @@ -126,7 +131,7 @@ function TransactionItemRow({ scrollToNewTransaction, isReportItemChild = false, isActionLoading, - shouldUseAnimatedHighlight = false, + isInReportTableView = false, }: TransactionItemRowProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -311,7 +316,7 @@ function TransactionItemRow({ > {shouldUseNarrowLayout ? ( - + {shouldShowCheckbox && ( @@ -387,7 +392,7 @@ function TransactionItemRow({ /> )} - @@ -400,7 +405,7 @@ function TransactionItemRow({ ) : ( - + @@ -415,7 +420,12 @@ function TransactionItemRow({ {columns?.map((column) => columnComponent[column])} - + {} + {isInReportTableView ? ( + + ) : ( + // We are rendering this component only if we are not in the report table view for performance reasons + )} )} diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 959f6d3bfd31..ef77744dd0e1 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -62,7 +62,13 @@ import { import {buildCannedSearchQuery, buildQueryStringFromFilterFormValues} from './SearchQueryUtils'; import StringUtils from './StringUtils'; import {shouldRestrictUserBillableActions} from './SubscriptionUtils'; -import {getAmount as getTransactionAmount, getCreated as getTransactionCreatedDate, getMerchant as getTransactionMerchant, isPendingCardOrScanningTransaction} from './TransactionUtils'; +import { + getAmount as getTransactionAmount, + getCreated as getTransactionCreatedDate, + getMerchant as getTransactionMerchant, + isPendingCardOrScanningTransaction, + isViolationDismissed, +} from './TransactionUtils'; import shouldShowTransactionYear from './TransactionUtils/shouldShowTransactionYear'; const transactionColumnNamesToSortingProperty = { @@ -316,6 +322,14 @@ function shouldShowYear(data: TransactionListItemType[] | ReportListItemType[] | return false; } +/** + * @private + * Extracts all transaction violations from the search data. + */ +function getViolations(data: OnyxTypes.SearchResults['data']): OnyxCollection { + return Object.fromEntries(Object.entries(data).filter(([key]) => isViolationEntry(key))) as OnyxCollection; +} + /** * @private * Generates a display name for IOU reports considering the personal details of the payer and the transaction details. @@ -339,6 +353,14 @@ function getIOUReportName(data: OnyxTypes.SearchResults['data'], reportItem: Sea }); } +function getTransactionViolations(allViolations: OnyxCollection, transaction: SearchTransaction): OnyxTypes.TransactionViolation[] { + const transactionViolations = allViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`]; + if (!transactionViolations) { + return []; + } + return transactionViolations.filter((violation) => !isViolationDismissed(transaction, violation)); +} + /** * @private * Organizes data into List Sections for display, for the TransactionListItemType of Search Results. @@ -354,6 +376,8 @@ function getTransactionsSections(data: OnyxTypes.SearchResults['data'], metadata // Pre-filter transaction keys to avoid repeated checks const transactionKeys = Object.keys(data).filter(isTransactionEntry); + // Get violations - optimize by using a Map for faster lookups + const allViolations = getViolations(data); // Use Map for faster lookups of personal details const personalDetailsMap = new Map(Object.entries(data.personalDetailsList || {})); @@ -366,6 +390,7 @@ function getTransactionsSections(data: OnyxTypes.SearchResults['data'], metadata const policy = data[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]; const shouldShowBlankTo = isOpenExpenseReport(report); + const transactionViolations = getTransactionViolations(allViolations, transactionItem); // Use Map.get() for faster lookups with default values const from = personalDetailsMap.get(transactionItem.accountID.toString()) ?? emptyPersonalDetails; const to = transactionItem.managerID && !shouldShowBlankTo ? (personalDetailsMap.get(transactionItem.managerID.toString()) ?? emptyPersonalDetails) : emptyPersonalDetails; @@ -373,7 +398,7 @@ function getTransactionsSections(data: OnyxTypes.SearchResults['data'], metadata const {formattedFrom, formattedTo, formattedTotal, formattedMerchant, date} = getTransactionItemCommonFormattedProperties(transactionItem, from, to, policy); const transactionSection: TransactionListItemType = { - action: getAction(data, key), + action: getAction(data, allViolations, key), from, to, formattedFrom, @@ -387,6 +412,7 @@ function getTransactionsSections(data: OnyxTypes.SearchResults['data'], metadata shouldShowTax, keyForList: transactionItem.transactionID, shouldShowYear: doesDataContainAPastYearTransaction, + violations: transactionViolations, // Manually copying all the properties from transactionItem transactionID: transactionItem.transactionID, @@ -432,14 +458,6 @@ function getTransactionsForReport(data: OnyxTypes.SearchResults['data'], reportI .map(([, value]) => value as SearchTransaction); } -/** - * @private - * Extracts all transaction violations from the search data. - */ -function getViolations(data: OnyxTypes.SearchResults['data']): OnyxCollection { - return Object.fromEntries(Object.entries(data).filter(([key]) => isViolationEntry(key))) as OnyxCollection; -} - /** * @private * Retrieves a report from the search data based on the provided key. @@ -503,7 +521,7 @@ function getReviewerPermissionFlags( * * Do not use directly, use only via `getSections()` facade. */ -function getAction(data: OnyxTypes.SearchResults['data'], key: string): SearchTransactionAction { +function getAction(data: OnyxTypes.SearchResults['data'], allViolations: OnyxCollection, key: string): SearchTransactionAction { const isTransaction = isTransactionEntry(key); const report = getReportFromKey(data, key); @@ -540,8 +558,7 @@ function getAction(data: OnyxTypes.SearchResults['data'], key: string): SearchTr } else { allReportTransactions = transaction ? [transaction] : []; } - // Get violations - optimize by using a Map for faster lookups - const allViolations = getViolations(data); + const policy = getPolicyFromKey(data, report) as OnyxTypes.Policy; const {isSubmitter, isAdmin, isApprover} = getReviewerPermissionFlags(report, policy); @@ -720,6 +737,8 @@ function getReportSections(data: OnyxTypes.SearchResults['data'], metadata: Onyx const shouldShowMerchant = getShouldShowMerchant(data); const doesDataContainAPastYearTransaction = shouldShowYear(data); + // Get violations - optimize by using a Map for faster lookups + const allViolations = getViolations(data); const reportIDToTransactions: Record = {}; for (const key in data) { @@ -731,7 +750,7 @@ function getReportSections(data: OnyxTypes.SearchResults['data'], metadata: Onyx reportIDToTransactions[reportKey] = { ...reportItem, - action: getAction(data, key), + action: getAction(data, allViolations, key), keyForList: reportItem.reportID, from: data.personalDetailsList?.[reportItem.accountID ?? CONST.DEFAULT_NUMBER_ID], to: reportItem.managerID ? data.personalDetailsList?.[reportItem.managerID] : emptyPersonalDetails, @@ -747,6 +766,7 @@ function getReportSections(data: OnyxTypes.SearchResults['data'], metadata: Onyx const report = data[`${ONYXKEYS.COLLECTION.REPORT}${transactionItem.reportID}`]; const policy = data[`${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`]; const shouldShowBlankTo = isOpenExpenseReport(report); + const transactionViolations = getTransactionViolations(allViolations, transactionItem); const from = data.personalDetailsList?.[transactionItem.accountID]; const to = transactionItem.managerID && !shouldShowBlankTo ? (data.personalDetailsList?.[transactionItem.managerID] ?? emptyPersonalDetails) : emptyPersonalDetails; @@ -755,7 +775,7 @@ function getReportSections(data: OnyxTypes.SearchResults['data'], metadata: Onyx const transaction = { ...transactionItem, - action: getAction(data, key), + action: getAction(data, allViolations, key), from, to, formattedFrom, @@ -769,6 +789,7 @@ function getReportSections(data: OnyxTypes.SearchResults['data'], metadata: Onyx shouldShowTax: metadata?.columnsToShow?.shouldShowTaxColumn, keyForList: transactionItem.transactionID, shouldShowYear: doesDataContainAPastYearTransaction, + violations: transactionViolations, }; if (reportIDToTransactions[reportKey]?.transactions) { reportIDToTransactions[reportKey].transactions.push(transaction); From 8b43627a9dc719f106c997291dd57688a472dd33 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Wed, 4 Jun 2025 07:54:27 +0200 Subject: [PATCH 19/21] update SearchUIUtilsTest to new action format --- cspell.json | 1 + tests/unit/Search/SearchUIUtilsTest.ts | 46 ++++++++++++++++++-------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/cspell.json b/cspell.json index 183fe18ac807..4d937bad3e3c 100644 --- a/cspell.json +++ b/cspell.json @@ -265,6 +265,7 @@ "islarge", "ismedium", "isnonreimbursable", + "issmall", "ITSM", "Jakub", "janky", diff --git a/tests/unit/Search/SearchUIUtilsTest.ts b/tests/unit/Search/SearchUIUtilsTest.ts index f0c1a2325f0a..78aa17f3f809 100644 --- a/tests/unit/Search/SearchUIUtilsTest.ts +++ b/tests/unit/Search/SearchUIUtilsTest.ts @@ -29,6 +29,15 @@ const transactionID2 = '2'; const transactionID3 = '3'; const transactionID4 = '4'; +const allViolations = { + [`transactionViolations_${transactionID2}`]: [ + { + name: CONST.VIOLATIONS.MISSING_CATEGORY, + type: CONST.VIOLATION_TYPES.VIOLATION, + }, + ], +}; + // Given search data results consisting of involved users' personal details, policyID, reportID and transactionID const searchResults: OnyxTypes.SearchResults = { data: { @@ -288,12 +297,7 @@ const searchResults: OnyxTypes.SearchResults = { errors: undefined, isActionLoading: false, }, - [`transactionViolations_${transactionID2}`]: [ - { - name: CONST.VIOLATIONS.MISSING_CATEGORY, - type: CONST.VIOLATION_TYPES.VIOLATION, - }, - ], + ...allViolations, [`transactions_${transactionID3}`]: { accountID: adminAccountID, amount: 1200, @@ -484,6 +488,7 @@ const transactionsListItems = [ errors: undefined, isActionLoading: false, hasViolation: false, + violations: [], }, { accountID: 18439984, @@ -545,6 +550,12 @@ const transactionsListItems = [ errors: undefined, isActionLoading: false, hasViolation: true, + violations: [ + { + name: CONST.VIOLATIONS.MISSING_CATEGORY, + type: CONST.VIOLATION_TYPES.VIOLATION, + }, + ], }, { accountID: 18439984, @@ -606,6 +617,7 @@ const transactionsListItems = [ errors: undefined, isActionLoading: false, hasViolation: undefined, + violations: [], }, { accountID: 18439984, @@ -667,6 +679,7 @@ const transactionsListItems = [ errors: undefined, isActionLoading: false, hasViolation: undefined, + violations: [], }, ] as TransactionListItemType[]; @@ -763,6 +776,7 @@ const reportsListItems = [ pendingAction: undefined, errors: undefined, isActionLoading: false, + violations: [], }, ], type: 'expense', @@ -825,6 +839,12 @@ const reportsListItems = [ }, hasEReceipt: false, hasViolation: true, + violations: [ + { + name: CONST.VIOLATIONS.MISSING_CATEGORY, + type: CONST.VIOLATION_TYPES.VIOLATION, + }, + ], isFromOneTransactionReport: true, keyForList: '2', managerID: 18439984, @@ -909,18 +929,18 @@ const reportsListItems = [ describe('SearchUIUtils', () => { describe('Test getAction', () => { test('Should return `Submit` action for transaction on policy with delayed submission and no violations', () => { - let action = SearchUIUtils.getAction(searchResults.data, `report_${reportID}`); + let action = SearchUIUtils.getAction(searchResults.data, {}, `report_${reportID}`); expect(action).toStrictEqual(CONST.SEARCH.ACTION_TYPES.SUBMIT); - action = SearchUIUtils.getAction(searchResults.data, `transactions_${transactionID}`); + action = SearchUIUtils.getAction(searchResults.data, {}, `transactions_${transactionID}`); expect(action).toStrictEqual(CONST.SEARCH.ACTION_TYPES.SUBMIT); }); test('Should return `Review` action for transaction on policy with delayed submission and with violations', () => { - let action = SearchUIUtils.getAction(searchResults.data, `report_${reportID2}`); + let action = SearchUIUtils.getAction(searchResults.data, allViolations, `report_${reportID2}`); expect(action).toStrictEqual(CONST.SEARCH.ACTION_TYPES.REVIEW); - action = SearchUIUtils.getAction(searchResults.data, `transactions_${transactionID2}`); + action = SearchUIUtils.getAction(searchResults.data, allViolations, `transactions_${transactionID2}`); expect(action).toStrictEqual(CONST.SEARCH.ACTION_TYPES.REVIEW); }); }); @@ -1071,10 +1091,10 @@ describe('SearchUIUtils', () => { Onyx.merge(ONYXKEYS.SESSION, {accountID: overlimitApproverAccountID}); searchResults.data[`policy_${policyID}`].role = CONST.POLICY.ROLE.USER; return waitForBatchedUpdates().then(() => { - let action = SearchUIUtils.getAction(searchResults.data, `report_${reportID2}`); + let action = SearchUIUtils.getAction(searchResults.data, allViolations, `report_${reportID2}`); expect(action).toEqual(CONST.SEARCH.ACTION_TYPES.VIEW); - action = SearchUIUtils.getAction(searchResults.data, `transactions_${transactionID2}`); + action = SearchUIUtils.getAction(searchResults.data, allViolations, `transactions_${transactionID2}`); expect(action).toEqual(CONST.SEARCH.ACTION_TYPES.VIEW); }); }); @@ -1201,7 +1221,7 @@ describe('SearchUIUtils', () => { }, }; return waitForBatchedUpdates().then(() => { - const action = SearchUIUtils.getAction(result.data, 'report_6523565988285061'); + const action = SearchUIUtils.getAction(result.data, allViolations, 'report_6523565988285061'); expect(action).toEqual(CONST.SEARCH.ACTION_TYPES.APPROVE); }); }); From c60d674a587600fbcf007de851738749f2a2495b Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Wed, 4 Jun 2025 08:14:43 +0200 Subject: [PATCH 20/21] fix wrong color in item selection --- src/components/TransactionItemRow/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TransactionItemRow/index.tsx b/src/components/TransactionItemRow/index.tsx index f34179bd8f74..a7eca1f30eca 100644 --- a/src/components/TransactionItemRow/index.tsx +++ b/src/components/TransactionItemRow/index.tsx @@ -227,7 +227,7 @@ function TransactionItemRow({ {!!transactionItem.action && ( Date: Wed, 4 Jun 2025 12:26:00 +0200 Subject: [PATCH 21/21] fix overflowing text --- src/components/TransactionItemRow/DataCells/MerchantCell.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TransactionItemRow/DataCells/MerchantCell.tsx b/src/components/TransactionItemRow/DataCells/MerchantCell.tsx index a0db1aa25e7f..a308355e94f5 100644 --- a/src/components/TransactionItemRow/DataCells/MerchantCell.tsx +++ b/src/components/TransactionItemRow/DataCells/MerchantCell.tsx @@ -17,7 +17,7 @@ function MerchantOrDescriptionCell({ ); }