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

Track expense #40988

Merged
merged 7 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 8 additions & 3 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,12 @@ function MoneyRequestView({
const distance = DistanceRequestUtils.convertToDistanceInMeters((transaction?.comment?.customUnit?.quantity as number) ?? 0, unit);
const rateToDisplay = DistanceRequestUtils.getRateForDisplay(unit, rate, currency, translate, toLocaleDigit, isOffline);
const distanceToDisplay = DistanceRequestUtils.getDistanceForDisplay(hasRoute, distance, unit, rate, translate);

let merchantTitle = isEmptyMerchant ? '' : transactionMerchant;
let amountTitle = formattedTransactionAmount ? formattedTransactionAmount.toString() : '';
if (TransactionUtils.hasReceipt(transaction) && TransactionUtils.isReceiptBeingScanned(transaction)) {
merchantTitle = translate('iou.receiptStatusTitle');
amountTitle = translate('iou.receiptStatusTitle');
}
const saveBillable = useCallback(
(newBillable: boolean) => {
// If the value hasn't changed, don't request to save changes on the server and just close the modal
Expand Down Expand Up @@ -373,7 +378,7 @@ function MoneyRequestView({
{canUseViolations && <ViolationMessages violations={getViolationsForField('receipt')} />}
<OfflineWithFeedback pendingAction={getPendingFieldAction('amount')}>
<MenuItemWithTopDescription
title={formattedTransactionAmount ? formattedTransactionAmount.toString() : ''}
title={amountTitle}
shouldShowTitleIcon={isSettled}
titleIcon={Expensicons.Checkmark}
description={amountDescription}
Expand Down Expand Up @@ -406,7 +411,7 @@ function MoneyRequestView({
<OfflineWithFeedback pendingAction={getPendingFieldAction('merchant')}>
<MenuItemWithTopDescription
description={translate('common.merchant')}
title={isEmptyMerchant ? '' : transactionMerchant}
title={merchantTitle}
interactive={canEditMerchant}
shouldShowRightIcon={canEditMerchant}
titleStyle={styles.flex1}
Expand Down
36 changes: 15 additions & 21 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2623,24 +2623,9 @@ function getTransactionReportName(reportAction: OnyxEntry<ReportAction | Optimis

const transaction = getLinkedTransaction(reportAction);

if (ReportActionsUtils.isTrackExpenseAction(reportAction)) {
if (isEmptyObject(transaction)) {
return Localize.translateLocal('iou.trackExpense');
}
const transactionDetails = getTransactionDetails(transaction);
return Localize.translateLocal('iou.threadTrackReportName', {
formattedAmount: CurrencyUtils.convertToDisplayString(transactionDetails?.amount ?? 0, transactionDetails?.currency) ?? '',
comment: (!TransactionUtils.isMerchantMissing(transaction) ? transactionDetails?.merchant : transactionDetails?.comment) ?? '',
});
}

if (isEmptyObject(transaction)) {
// Transaction data might be empty on app's first load, if so we fallback to Expense
return Localize.translateLocal('iou.expense');
}

if (TransactionUtils.isFetchingWaypointsFromServer(transaction)) {
return Localize.translateLocal('iou.fieldPending');
// Transaction data might be empty on app's first load, if so we fallback to Expense/Track Expense
return ReportActionsUtils.isTrackExpenseAction(reportAction) ? Localize.translateLocal('iou.trackExpense') : Localize.translateLocal('iou.expense');
}

if (TransactionUtils.hasReceipt(transaction) && TransactionUtils.isReceiptBeingScanned(transaction)) {
Expand All @@ -2651,12 +2636,21 @@ function getTransactionReportName(reportAction: OnyxEntry<ReportAction | Optimis
return Localize.translateLocal('iou.receiptMissingDetails');
}

if (TransactionUtils.isFetchingWaypointsFromServer(transaction)) {
return Localize.translateLocal('iou.fieldPending');
}

const transactionDetails = getTransactionDetails(transaction);

return Localize.translateLocal(ReportActionsUtils.isSentMoneyReportAction(reportAction) ? 'iou.threadPaySomeoneReportName' : 'iou.threadExpenseReportName', {
formattedAmount: CurrencyUtils.convertToDisplayString(transactionDetails?.amount ?? 0, transactionDetails?.currency) ?? '',
comment: (!TransactionUtils.isMerchantMissing(transaction) ? transactionDetails?.merchant : transactionDetails?.comment) ?? '',
});
const formattedAmount = CurrencyUtils.convertToDisplayString(transactionDetails?.amount ?? 0, transactionDetails?.currency) ?? '';
const comment = (!TransactionUtils.isMerchantMissing(transaction) ? transactionDetails?.merchant : transactionDetails?.comment) ?? '';
if (ReportActionsUtils.isTrackExpenseAction(reportAction)) {
return Localize.translateLocal('iou.threadTrackReportName', {formattedAmount, comment});
}
if (ReportActionsUtils.isSentMoneyReportAction(reportAction)) {
return Localize.translateLocal('iou.threadPaySomeoneReportName', {formattedAmount, comment});
}
return Localize.translateLocal('iou.threadExpenseReportName', {formattedAmount, comment});
}

/**
Expand Down
Loading