Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Scanning expense displays 0.00 in Total column and the Merchant column is blank #44190

Merged
merged 10 commits into from
Jun 25, 2024
18 changes: 16 additions & 2 deletions src/components/SelectionList/Search/TransactionListItemRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as Expensicons from '@components/Icon/Expensicons';
import ReceiptImage from '@components/ReceiptImage';
import type {TransactionListItemType} from '@components/SelectionList/types';
import TextWithTooltip from '@components/TextWithTooltip';
import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -106,24 +107,37 @@ function DateCell({transactionItem, showTooltip, isLargeScreenWidth}: Transactio

function MerchantCell({transactionItem, showTooltip, isLargeScreenWidth}: TransactionCellProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const description = TransactionUtils.getDescription(transactionItem);
let merchant = transactionItem.shouldShowMerchant ? transactionItem.formattedMerchant : description;

if (TransactionUtils.hasReceipt(transactionItem) && TransactionUtils.isReceiptBeingScanned(transactionItem)) {
merchant = translate('iou.receiptStatusTitle');
}

return (
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={transactionItem.shouldShowMerchant ? transactionItem.formattedMerchant : description}
text={merchant}
style={[isLargeScreenWidth ? styles.lineHeightLarge : styles.lh20, styles.pre, styles.justifyContentCenter]}
/>
);
}

function TotalCell({showTooltip, isLargeScreenWidth, transactionItem}: TotalCellProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const currency = TransactionUtils.getCurrency(transactionItem);
let amount = CurrencyUtils.convertToDisplayString(transactionItem.formattedTotal, currency);

if (TransactionUtils.hasReceipt(transactionItem) && TransactionUtils.isReceiptBeingScanned(transactionItem)) {
amount = translate('iou.receiptStatusTitle');
}

return (
<TextWithTooltip
shouldShowTooltip={showTooltip}
text={CurrencyUtils.convertToDisplayString(transactionItem.formattedTotal, currency)}
text={amount}
style={[styles.optionDisplayName, styles.justifyContentCenter, isLargeScreenWidth ? undefined : styles.textAlignRight]}
/>
);
Expand Down
3 changes: 3 additions & 0 deletions src/types/onyx/SearchResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ type SearchTransaction = {
receipt?: {
/** Source of the receipt */
source?: string;

/** State of the receipt */
state?: ValueOf<typeof CONST.IOU.RECEIPT_STATE>;
};

/** The transaction tag */
Expand Down
Loading