Skip to content

Commit

Permalink
show the requestor name for non-reimburseable transaction on the LHN …
Browse files Browse the repository at this point in the history
…alternate text and IOU report header
  • Loading branch information
mollfpr committed Mar 5, 2024
1 parent 3f7d952 commit e043a78
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2072,8 +2072,7 @@ function getMoneyRequestReportName(report: OnyxEntry<Report>, policy: OnyxEntry<

const moneyRequestTotal = getMoneyRequestSpendBreakdown(report).totalDisplaySpend;
const formattedAmount = CurrencyUtils.convertToDisplayString(moneyRequestTotal, report?.currency);
const payerOrApproverName =
isExpenseReport(report) && !hasNonReimbursableTransactions(report?.reportID ?? '') ? getPolicyName(report, false, policy) : getDisplayNameForParticipant(report?.managerID) ?? '';
let payerOrApproverName = isExpenseReport(report) ? getPolicyName(report, false, policy) : getDisplayNameForParticipant(report?.managerID) ?? '';
const payerPaidAmountMessage = Localize.translateLocal('iou.payerPaidAmount', {
payer: payerOrApproverName,
amount: formattedAmount,
Expand All @@ -2090,7 +2089,8 @@ function getMoneyRequestReportName(report: OnyxEntry<Report>, policy: OnyxEntry<
return `${payerPaidAmountMessage}${Localize.translateLocal('iou.pending')}`;
}

if (hasNonReimbursableTransactions(report?.reportID)) {
if (!isSettled(report?.reportID) && hasNonReimbursableTransactions(report?.reportID)) {
payerOrApproverName = getDisplayNameForParticipant(report?.ownerAccountID) ?? '';
return Localize.translateLocal('iou.payerSpentAmount', {payer: payerOrApproverName, amount: formattedAmount});
}

Expand Down Expand Up @@ -2374,7 +2374,7 @@ function getReportPreviewMessage(
const containsNonReimbursable = hasNonReimbursableTransactions(report.reportID);
const totalAmount = getMoneyRequestSpendBreakdown(report).totalDisplaySpend;
const policyName = getPolicyName(report, false, policy);
const payerName = isExpenseReport(report) && !containsNonReimbursable ? policyName : getDisplayNameForParticipant(report.managerID, !isPreviewMessageForParentChatReport);
const payerName = isExpenseReport(report) ? policyName : getDisplayNameForParticipant(report.managerID, !isPreviewMessageForParentChatReport);

const formattedAmount = CurrencyUtils.convertToDisplayString(totalAmount, report.currency);

Expand Down Expand Up @@ -2444,7 +2444,11 @@ function getReportPreviewMessage(
return `${requestorName ? `${requestorName}: ` : ''}${Localize.translateLocal('iou.requestedAmount', {formattedAmount: amountToDisplay})}`;
}

return Localize.translateLocal(containsNonReimbursable ? 'iou.payerSpentAmount' : 'iou.payerOwesAmount', {payer: payerName ?? '', amount: formattedAmount});
if (containsNonReimbursable) {
return Localize.translateLocal('iou.payerSpentAmount', {payer: getDisplayNameForParticipant(report.ownerAccountID) ?? '', amount: formattedAmount});
}

return Localize.translateLocal('iou.payerOwesAmount', {payer: payerName ?? '', amount: formattedAmount});
}

/**
Expand Down

0 comments on commit e043a78

Please sign in to comment.