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: On pay money, description in preview #41963

Merged
merged 5 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ const CONST = {
DARK_CONTENT: 'dark-content',
},
TRANSACTION: {
DEFAULT_MERCHANT: 'Request',
DEFAULT_MERCHANT: 'Expense',
UNKNOWN_MERCHANT: 'Unknown Merchant',
PARTIAL_TRANSACTION_MERCHANT: '(none)',
TYPE: {
Expand Down
14 changes: 9 additions & 5 deletions src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import React, {useMemo} from 'react';
import type {StyleProp, ViewStyle} from 'react-native';
import {View} from 'react-native';
Expand All @@ -20,7 +21,6 @@ import * as CurrencyUtils from '@libs/CurrencyUtils';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import Navigation from '@libs/Navigation/Navigation';
import * as ReceiptUtils from '@libs/ReceiptUtils';
import * as ReportActionUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import type {ContextMenuAnchor} from '@pages/home/report/ContextMenu/ReportActionContextMenu';
Expand Down Expand Up @@ -120,14 +120,14 @@ function ReportPreview({
const {totalDisplaySpend, reimbursableSpend} = ReportUtils.getMoneyRequestSpendBreakdown(iouReport);

const iouSettled = ReportUtils.isSettled(iouReportID);
const numberOfRequests = ReportActionUtils.getNumberOfMoneyRequests(action);
const moneyRequestComment = action?.childLastMoneyRequestComment ?? '';
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport);
const isOpenExpenseReport = isPolicyExpenseChat && ReportUtils.isOpenExpenseReport(iouReport);

const isApproved = ReportUtils.isReportApproved(iouReport);
const canAllowSettlement = ReportUtils.hasUpdatedTotal(iouReport, policy);
const allTransactions = TransactionUtils.getAllReportTransactions(iouReportID);
const numberOfRequests = allTransactions.length;
const transactionsWithReceipts = ReportUtils.getTransactionsWithReceipts(iouReportID);
const numberOfScanningReceipts = transactionsWithReceipts.filter((transaction) => TransactionUtils.isReceiptBeingScanned(transaction)).length;
const numberOfPendingRequests = transactionsWithReceipts.filter((transaction) => TransactionUtils.isPending(transaction) && TransactionUtils.isCardTransaction(transaction)).length;
Expand Down Expand Up @@ -226,11 +226,15 @@ function ReportPreview({
const shouldShowSubtitle = !isScanning && (shouldShowSingleRequestMerchantOrDescription || numberOfRequests > 1);

const {supportText} = useMemo(() => {
if (formattedMerchant) {
return {supportText: formattedMerchant};
if (formattedMerchant && formattedMerchant !== CONST.TRANSACTION.DEFAULT_MERCHANT) {
return {isSupportTextHtml: false, supportText: formattedMerchant};
}
if (formattedDescription ?? moneyRequestComment) {
return {supportText: formattedDescription ?? moneyRequestComment};
const parsedSubtitle = new ExpensiMark().replace(formattedDescription ?? moneyRequestComment);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this change is outdated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DylanDylann i updated, please check again

return {isSupportTextHtml: !!parsedSubtitle, supportText: parsedSubtitle};
}
if (formattedMerchant === CONST.TRANSACTION.DEFAULT_MERCHANT) {
return {isSupportTextHtml: false, supportText: formattedMerchant};
}
return {
supportText: translate('iou.expenseCount', {
Expand Down
Loading