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: IOU description can't be seen on the LHN reports #34840

Merged
merged 27 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bd5f177
Include comment in report name for amounts owing
tobyjsullivan Nov 25, 2023
ee2c15d
Reuse translateLocal call
tobyjsullivan Jan 19, 2024
eeca194
Remove redundant type declaration
tobyjsullivan Jan 19, 2024
db0d8d1
Avoid variable reassignments
tobyjsullivan Jan 19, 2024
c2731c0
Remove unrelated code change
tobyjsullivan Jan 19, 2024
036ac5c
Update editRegularMoneyTransaction
tobyjsullivan Jan 19, 2024
40073f0
Include request description when request deleted
tobyjsullivan Jan 20, 2024
f7032dd
Include IOU description in report name
tobyjsullivan Jan 20, 2024
2e2ac1f
Run prettier and lint
tobyjsullivan Jan 20, 2024
62035fc
Merge branch 'main' into fix/31859
tobyjsullivan Jan 22, 2024
719d63d
Undo changes to text outside LHN preview
tobyjsullivan Jan 26, 2024
e48ebb1
Display report description for 1-to-1 money request
tobyjsullivan Jan 30, 2024
a3af0b1
Merge branch 'main' into fix/31859
tobyjsullivan Feb 6, 2024
1ad742d
Fix prettier formatting
tobyjsullivan Feb 6, 2024
a15267d
Merge remote-tracking branch 'expensify/main' into fix/31859
tobyjsullivan Feb 9, 2024
26e354f
Fix formatting error
tobyjsullivan Feb 12, 2024
2a9eda7
Merge branch 'main' into fix/31859
tobyjsullivan Feb 20, 2024
ce88328
Get linked transaction only when absent
tobyjsullivan Feb 21, 2024
f8e1caa
Merge branch 'main' into fix/31859
tobyjsullivan Feb 21, 2024
6a4d690
Merge branch 'main' into fix/31859
tobyjsullivan Feb 26, 2024
f011e58
Hide description when last message is multi-request preview
tobyjsullivan Feb 27, 2024
80befc4
Merge branch 'main' into fix/31859
tobyjsullivan Feb 27, 2024
a818f52
Tidy up conditions for request descriptions
tobyjsullivan Feb 27, 2024
40b0c6f
Merge branch 'main' into fix/31859
tobyjsullivan Mar 6, 2024
89418e8
Add and update comments for report action params
tobyjsullivan Mar 6, 2024
7bf59f8
Merge branch 'main' into fix/31859
tobyjsullivan Mar 11, 2024
defc91c
Merge branch 'main' into fix/31859
tobyjsullivan Mar 18, 2024
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/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ export default {
splitAmount: ({amount}: SplitAmountParams) => `split ${amount}`,
didSplitAmount: ({formattedAmount, comment}: DidSplitAmountMessageParams) => `split ${formattedAmount}${comment ? ` for ${comment}` : ''}`,
amountEach: ({amount}: AmountEachParams) => `${amount} each`,
payerOwesAmount: ({payer, amount}: PayerOwesAmountParams) => `${payer} owes ${amount}`,
payerOwesAmount: ({payer, amount, comment}: PayerOwesAmountParams) => `${payer} owes ${amount}${comment ? ` for ${comment}` : ''}`,
payerOwes: ({payer}: PayerOwesParams) => `${payer} owes: `,
payerPaidAmount: ({payer, amount}: PayerPaidAmountParams): string => `${payer ? `${payer} ` : ''}paid ${amount}`,
payerPaid: ({payer}: PayerPaidParams) => `${payer} paid: `,
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ export default {
splitAmount: ({amount}: SplitAmountParams) => `dividir ${amount}`,
didSplitAmount: ({formattedAmount, comment}: DidSplitAmountMessageParams) => `dividió ${formattedAmount}${comment ? ` para ${comment}` : ''}`,
amountEach: ({amount}: AmountEachParams) => `${amount} cada uno`,
payerOwesAmount: ({payer, amount}: PayerOwesAmountParams) => `${payer} debe ${amount}`,
payerOwesAmount: ({payer, amount, comment}: PayerOwesAmountParams) => `${payer} debe ${amount}${comment ? ` para ${comment}` : ''}`,
payerOwes: ({payer}: PayerOwesParams) => `${payer} debe: `,
payerPaidAmount: ({payer, amount}: PayerPaidAmountParams) => `${payer ? `${payer} ` : ''}pagó ${amount}`,
payerPaid: ({payer}: PayerPaidParams) => `${payer} pagó: `,
Expand Down
2 changes: 1 addition & 1 deletion src/languages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type DidSplitAmountMessageParams = {formattedAmount: string; comment: string};

type AmountEachParams = {amount: string};

type PayerOwesAmountParams = {payer: string; amount: number | string};
type PayerOwesAmountParams = {payer: string; amount: number | string; comment?: string};

type PayerOwesParams = {payer: string};

Expand Down
1 change: 1 addition & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
ReportUtils.isChatReport(report),
null,
true,
lastReportAction,
);
} else if (ReportActionUtils.isReimbursementQueuedAction(lastReportAction)) {
lastMessageTextFromReport = ReportUtils.getReimbursementQueuedActionMessage(lastReportAction, report);
Expand Down
39 changes: 28 additions & 11 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2414,27 +2414,31 @@ function getTransactionReportName(reportAction: OnyxEntry<ReportAction | Optimis
/**
* Get money request message for an IOU report
*
* @param [reportAction] This can be either a report preview action or the IOU action
* @param [iouReportAction] This is always an IOU action. When necessary, report preview actions will be unwrapped and the child iou report action is passed here (the original report preview
* action will be passed as `originalReportAction` in this case).
* @param [originalReportAction] This can be either a report preview action or the IOU action. This will be the original report preview action in cases where `iouReportAction` was unwrapped
* from a report preview action. Otherwise, it will be the same as `iouReportAction`.
*/
function getReportPreviewMessage(
report: OnyxEntry<Report> | EmptyObject,
reportAction: OnyxEntry<ReportAction> | EmptyObject = {},
iouReportAction: OnyxEntry<ReportAction> | EmptyObject = {},
shouldConsiderScanningReceiptOrPendingRoute = false,
isPreviewMessageForParentChatReport = false,
policy: OnyxEntry<Policy> = null,
isForListPreview = false,
originalReportAction: OnyxEntry<ReportAction> | EmptyObject = iouReportAction,
): string {
const reportActionMessage = reportAction?.message?.[0].html ?? '';
const reportActionMessage = iouReportAction?.message?.[0].html ?? '';

if (isEmptyObject(report) || !report?.reportID) {
// The iouReport is not found locally after SignIn because the OpenApp API won't return iouReports if they're settled
// As a temporary solution until we know how to solve this the best, we just use the message that returned from BE
return reportActionMessage;
}

if (!isEmptyObject(reportAction) && !isIOUReport(report) && reportAction && ReportActionsUtils.isSplitBillAction(reportAction)) {
if (!isEmptyObject(iouReportAction) && !isIOUReport(report) && iouReportAction && ReportActionsUtils.isSplitBillAction(iouReportAction)) {
// This covers group chats where the last action is a split bill action
const linkedTransaction = getLinkedTransaction(reportAction);
const linkedTransaction = getLinkedTransaction(iouReportAction);
if (isEmptyObject(linkedTransaction)) {
return reportActionMessage;
}
Expand Down Expand Up @@ -2469,8 +2473,8 @@ function getReportPreviewMessage(
}

let linkedTransaction;
if (!isEmptyObject(reportAction) && shouldConsiderScanningReceiptOrPendingRoute && reportAction && ReportActionsUtils.isMoneyRequestAction(reportAction)) {
linkedTransaction = getLinkedTransaction(reportAction);
if (!isEmptyObject(iouReportAction) && shouldConsiderScanningReceiptOrPendingRoute && iouReportAction && ReportActionsUtils.isMoneyRequestAction(iouReportAction)) {
linkedTransaction = getLinkedTransaction(iouReportAction);
}

if (!isEmptyObject(linkedTransaction) && TransactionUtils.hasReceipt(linkedTransaction) && TransactionUtils.isReceiptBeingScanned(linkedTransaction)) {
Expand All @@ -2481,7 +2485,7 @@ function getReportPreviewMessage(
return Localize.translateLocal('iou.routePending');
}

const originalMessage = reportAction?.originalMessage as IOUMessage | undefined;
const originalMessage = iouReportAction?.originalMessage as IOUMessage | undefined;

// Show Paid preview message if it's settled or if the amount is paid & stuck at receivers end for only chat reports.
if (isSettled(report.reportID) || (report.isWaitingOnBankAccount && isPreviewMessageForParentChatReport)) {
Expand Down Expand Up @@ -2509,7 +2513,7 @@ function getReportPreviewMessage(
return Localize.translateLocal('iou.waitingOnBankAccount', {submitterDisplayName});
}

const lastActorID = reportAction?.actorAccountID;
const lastActorID = iouReportAction?.actorAccountID;
let amount = originalMessage?.amount;
let currency = originalMessage?.currency ? originalMessage?.currency : report.currency;

Expand All @@ -2518,16 +2522,29 @@ function getReportPreviewMessage(
currency = TransactionUtils.getCurrency(linkedTransaction);
}

if (isEmptyObject(linkedTransaction) && !isEmptyObject(iouReportAction)) {
linkedTransaction = getLinkedTransaction(iouReportAction);
}

let comment = !isEmptyObject(linkedTransaction) ? TransactionUtils.getDescription(linkedTransaction) : undefined;
if (!isEmptyObject(originalReportAction) && ReportActionsUtils.isReportPreviewAction(originalReportAction) && ReportActionsUtils.getNumberOfMoneyRequests(originalReportAction) !== 1) {
comment = undefined;
}

// if we have the amount in the originalMessage and lastActorID, we can use that to display the preview message for the latest request
if (amount !== undefined && lastActorID && !isPreviewMessageForParentChatReport) {
const amountToDisplay = CurrencyUtils.convertToDisplayString(Math.abs(amount), currency);

// We only want to show the actor name in the preview if it's not the current user who took the action
const requestorName = lastActorID && lastActorID !== currentUserAccountID ? getDisplayNameForParticipant(lastActorID, !isPreviewMessageForParentChatReport) : '';
return `${requestorName ? `${requestorName}: ` : ''}${Localize.translateLocal('iou.requestedAmount', {formattedAmount: amountToDisplay})}`;
return `${requestorName ? `${requestorName}: ` : ''}${Localize.translateLocal('iou.requestedAmount', {formattedAmount: amountToDisplay, comment})}`;
}

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

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

/**
Expand Down
Loading