From 561dc5aa631a8767b544536805a51ec6475641c4 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 8 Nov 2023 14:25:38 +0100 Subject: [PATCH 1/7] fix: fix lhn previews --- src/languages/en.ts | 10 ++++---- src/languages/es.ts | 10 ++++---- src/libs/OptionsListUtils.js | 46 +++++++++++++++++++++++++++++++++--- src/libs/ReportUtils.js | 39 ++++++++++++++++++++++++++---- 4 files changed, 88 insertions(+), 17 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 38efe0ef92f6..dd187d414424 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -557,19 +557,19 @@ 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}: PayerOwesAmountParams) => `${payer ? `${payer} ` : ''}owes ${amount}`, payerOwes: ({payer}: PayerOwesParams) => `${payer} owes: `, - payerPaidAmount: ({payer, amount}: PayerPaidAmountParams): string => `${payer} paid ${amount}`, + payerPaidAmount: ({payer, amount}: PayerPaidAmountParams): string => `${payer ? `${payer} ` : ''}paid ${amount}`, payerPaid: ({payer}: PayerPaidParams) => `${payer} paid: `, - payerSpentAmount: ({payer, amount}: PayerPaidAmountParams): string => `${payer} spent ${amount}`, + payerSpentAmount: ({payer, amount}: PayerPaidAmountParams): string => `${payer ? `${payer} ` : ''}spent ${amount}`, payerSpent: ({payer}: PayerPaidParams) => `${payer} spent: `, managerApproved: ({manager}: ManagerApprovedParams) => `${manager} approved:`, payerSettled: ({amount}: PayerSettledParams) => `paid ${amount}`, waitingOnBankAccount: ({submitterDisplayName}: WaitingOnBankAccountParams) => `started settling up, payment is held until ${submitterDisplayName} adds a bank account`, settledAfterAddedBankAccount: ({submitterDisplayName, amount}: SettledAfterAddedBankAccountParams) => `${submitterDisplayName} added a bank account. The ${amount} payment has been made.`, - paidElsewhereWithAmount: ({payer, amount}: PaidElsewhereWithAmountParams) => `${payer} paid ${amount} elsewhere`, - paidWithExpensifyWithAmount: ({payer, amount}: PaidWithExpensifyWithAmountParams) => `${payer} paid ${amount} using Expensify`, + paidElsewhereWithAmount: ({payer, amount}: PaidElsewhereWithAmountParams) => `${payer ? `${payer} ` : ''}paid ${amount} elsewhere`, + paidWithExpensifyWithAmount: ({payer, amount}: PaidWithExpensifyWithAmountParams) => `${payer ? `${payer} ` : ''}paid ${amount} using Expensify`, noReimbursableExpenses: 'This report has an invalid amount', pendingConversionMessage: "Total will update when you're back online", changedTheRequest: 'changed the request', diff --git a/src/languages/es.ts b/src/languages/es.ts index 2bdb71ae82f7..6c8f79b26f80 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -549,19 +549,19 @@ 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}: PayerOwesAmountParams) => `${payer ? `${payer} ` : ''}debe ${amount}`, payerOwes: ({payer}: PayerOwesParams) => `${payer} debe: `, - payerPaidAmount: ({payer, amount}: PayerPaidAmountParams) => `${payer} pagó ${amount}`, + payerPaidAmount: ({payer, amount}: PayerPaidAmountParams) => `${payer ? `${payer} ` : ''}pagó ${amount}`, payerPaid: ({payer}: PayerPaidParams) => `${payer} pagó: `, - payerSpentAmount: ({payer, amount}: PayerPaidAmountParams): string => `${payer} gastó ${amount}`, + payerSpentAmount: ({payer, amount}: PayerPaidAmountParams): string => `${payer ? `${payer} ` : ''}gastó ${amount}`, payerSpent: ({payer}: PayerPaidParams) => `${payer} gastó: `, managerApproved: ({manager}: ManagerApprovedParams) => `${manager} aprobó:`, payerSettled: ({amount}: PayerSettledParams) => `pagó ${amount}`, waitingOnBankAccount: ({submitterDisplayName}: WaitingOnBankAccountParams) => `inicio el pago, pero no se procesará hasta que ${submitterDisplayName} añada una cuenta bancaria`, settledAfterAddedBankAccount: ({submitterDisplayName, amount}: SettledAfterAddedBankAccountParams) => `${submitterDisplayName} añadió una cuenta bancaria. El pago de ${amount} se ha realizado.`, - paidElsewhereWithAmount: ({payer, amount}: PaidElsewhereWithAmountParams) => `${payer} pagó ${amount} de otra forma`, - paidWithExpensifyWithAmount: ({payer, amount}: PaidWithExpensifyWithAmountParams) => `${payer} pagó ${amount} con Expensify`, + paidElsewhereWithAmount: ({payer, amount}: PaidElsewhereWithAmountParams) => `${payer ? `${payer} ` : ''}pagó ${amount} de otra forma`, + paidWithExpensifyWithAmount: ({payer, amount}: PaidWithExpensifyWithAmountParams) => `${payer ? `${payer} ` : ''}pagó ${amount} con Expensify`, noReimbursableExpenses: 'El importe de este informe no es válido', pendingConversionMessage: 'El total se actualizará cuando estés online', changedTheRequest: 'cambió la solicitud', diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 54d09b75eff2..ae445a6e46a5 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -9,6 +9,7 @@ import _ from 'underscore'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import * as CollectionUtils from './CollectionUtils'; +import * as CurrencyUtils from './CurrencyUtils'; import * as ErrorUtils from './ErrorUtils'; import * as LocalePhoneNumber from './LocalePhoneNumber'; import * as Localize from './Localize'; @@ -372,6 +373,39 @@ function getAllReportErrors(report, reportActions) { return allReportErrors; } +/** + * Get the preview message to be displayed in the option list. + * @param {Object} report + * @param {Object} reportAction + * @param {Boolean} isPreviewMessageForParentChatReport + * @returns {String} + */ + +function getReportPreviewMessageForOptionList(report, reportAction, isPreviewMessageForParentChatReport = false) { + // for the request action preview we want to show the requestor instead of the user who owes the money + if (!isPreviewMessageForParentChatReport && reportAction.originalMessage && reportAction.originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE) { + const amount = Math.abs(reportAction.originalMessage.amount); + const formattedAmount = CurrencyUtils.convertToDisplayString(amount, report.currency); + const shouldShowActorName = currentUserAccountID !== reportAction.actorAccountID; + const actorDisplayName = shouldShowActorName ? `${ReportUtils.getDisplayNameForParticipant(reportAction.actorAccountID, true)}: ` : ''; + + return `${actorDisplayName}${Localize.translateLocal('iou.requestedAmount', {formattedAmount})}`; + } + + const shouldShowWorkspaceName = ReportUtils.isExpenseReport(report) && isPreviewMessageForParentChatReport; + const actor = ReportUtils.getActorNameForPreviewMessage({ + report, + shouldShowWorkspaceName, + actorID: reportAction.actorAccountID, + shouldUseShortForm: !isPreviewMessageForParentChatReport, + }); + const shouldShowActorName = shouldShowWorkspaceName || isPreviewMessageForParentChatReport || currentUserAccountID !== reportAction.actorAccountID; + const actorDisplayName = shouldShowActorName ? `${actor}${isPreviewMessageForParentChatReport ? ' ' : ': '}` : ''; + const message = ReportUtils.getReportPreviewMessage(report, reportAction, true, isPreviewMessageForParentChatReport, true); + + return `${actorDisplayName}${message}`; +} + /** * Get the last message text from the report directly or from other sources for special cases. * @param {Object} report @@ -385,10 +419,16 @@ function getLastMessageTextForReport(report) { let lastMessageTextFromReport = ''; const lastActionName = lodashGet(lastReportAction, 'actionName', ''); - if (ReportUtils.isReportMessageAttachment({text: report.lastMessageText, html: report.lastMessageHtml, translationKey: report.lastMessageTranslationKey})) { + if ( + ReportUtils.isReportMessageAttachment({ + text: report.lastMessageText, + html: report.lastMessageHtml, + translationKey: report.lastMessageTranslationKey, + }) + ) { lastMessageTextFromReport = `[${Localize.translateLocal(report.lastMessageTranslationKey || 'common.attachment')}]`; } else if (ReportActionUtils.isMoneyRequestAction(lastReportAction)) { - const properSchemaForMoneyRequestMessage = ReportUtils.getReportPreviewMessage(report, lastReportAction, true); + const properSchemaForMoneyRequestMessage = getReportPreviewMessageForOptionList(report, lastReportAction, false); lastMessageTextFromReport = ReportUtils.formatReportLastMessageText(properSchemaForMoneyRequestMessage); } else if (ReportActionUtils.isReportPreviewAction(lastReportAction)) { const iouReport = ReportUtils.getReport(ReportActionUtils.getIOUReportIDFromReportActionPreview(lastReportAction)); @@ -399,7 +439,7 @@ function getLastMessageTextForReport(report) { reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && ReportActionUtils.isMoneyRequestAction(reportAction), ); - lastMessageTextFromReport = ReportUtils.getReportPreviewMessage(iouReport, lastIOUMoneyReport, true, ReportUtils.isChatReport(report)); + lastMessageTextFromReport = getReportPreviewMessageForOptionList(iouReport, lastIOUMoneyReport, ReportUtils.isChatReport(report)); } else if (ReportActionUtils.isReimbursementQueuedAction(lastReportAction)) { lastMessageTextFromReport = ReportUtils.getReimbursementQueuedActionMessage(lastReportAction, report); } else if (ReportActionUtils.isDeletedParentAction(lastReportAction) && ReportUtils.isChatReport(report)) { diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 8d24d98b19e8..ef4d94702081 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1775,6 +1775,20 @@ function getTransactionReportName(reportAction) { }); } +/** + * Get actor name to display in the message preview + * + * @param {Object} report + * @param {Number} actorID + * @param {Boolean} shouldShowWorkspaceName + * @param {Boolean} shouldUseShortForm + * @returns {String} + */ + +function getActorNameForPreviewMessage({report, actorID, shouldShowWorkspaceName = false, shouldUseShortForm = false}) { + return shouldShowWorkspaceName ? getPolicyName(report) : getDisplayNameForParticipant(actorID, shouldUseShortForm); +} + /** * Get money request message for an IOU report * @@ -1782,9 +1796,10 @@ function getTransactionReportName(reportAction) { * @param {Object} [reportAction={}] This can be either a report preview action or the IOU action * @param {Boolean} [shouldConsiderReceiptBeingScanned=false] * @param {Boolean} isPreviewMessageForParentChatReport + * @param {Boolean} shouldHideParticipantName * @returns {String} */ -function getReportPreviewMessage(report, reportAction = {}, shouldConsiderReceiptBeingScanned = false, isPreviewMessageForParentChatReport = false) { +function getReportPreviewMessage(report, reportAction = {}, shouldConsiderReceiptBeingScanned = false, isPreviewMessageForParentChatReport = false, shouldHideParticipantName = false) { const reportActionMessage = lodashGet(reportAction, 'message[0].html', ''); if (_.isEmpty(report) || !report.reportID) { @@ -1808,7 +1823,13 @@ function getReportPreviewMessage(report, reportAction = {}, shouldConsiderReceip } const totalAmount = getMoneyRequestReimbursableTotal(report); - const payerName = isExpenseReport(report) ? getPolicyName(report) : getDisplayNameForParticipant(report.managerID, true); + const payerDisplayName = getActorNameForPreviewMessage({ + report, + actorID: report.managerID, + shouldUseShortForm: true, + shouldShowWorkspaceName: isExpenseReport(report), + }); + const payerName = shouldHideParticipantName ? '' : payerDisplayName; const formattedAmount = CurrencyUtils.convertToDisplayString(totalAmount, report.currency); if (isReportApproved(report) && getPolicyType(report, allPolicies) === CONST.POLICY.TYPE.CORPORATE) { @@ -1867,7 +1888,11 @@ function getProperSchemaForModifiedExpenseMessage(newValue, oldValue, valueName, if (!newValue) { return Localize.translateLocal('iou.removedTheRequest', {valueName: displayValueName, oldValueToDisplay}); } - return Localize.translateLocal('iou.updatedTheRequest', {valueName: displayValueName, newValueToDisplay, oldValueToDisplay}); + return Localize.translateLocal('iou.updatedTheRequest', { + valueName: displayValueName, + newValueToDisplay, + oldValueToDisplay, + }); } /** @@ -1882,7 +1907,10 @@ function getProperSchemaForModifiedExpenseMessage(newValue, oldValue, valueName, function getProperSchemaForModifiedDistanceMessage(newDistance, oldDistance, newAmount, oldAmount) { if (!oldDistance) { - return Localize.translateLocal('iou.setTheDistance', {newDistanceToDisplay: newDistance, newAmountToDisplay: newAmount}); + return Localize.translateLocal('iou.setTheDistance', { + newDistanceToDisplay: newDistance, + newAmountToDisplay: newAmount, + }); } return Localize.translateLocal('iou.updatedTheDistance', { newDistanceToDisplay: newDistance, @@ -2619,6 +2647,7 @@ function buildOptimisticIOUReportAction( whisperedToAccountIDs: _.contains([CONST.IOU.RECEIPT_STATE.SCANREADY, CONST.IOU.RECEIPT_STATE.SCANNING], receipt.state) ? [currentUserAccountID] : [], }; } + /** * Builds an optimistic APPROVED report action with a randomly generated reportActionID. * @@ -3257,6 +3286,7 @@ function canAccessReport(report, policies, betas, allReportActions) { return true; } + /** * Check if the report is the parent report of the currently viewed report or at least one child report has report action * @param {Object} report @@ -4328,4 +4358,5 @@ export { getReimbursementQueuedActionMessage, getPersonalDetailsForAccountID, getRoom, + getActorNameForPreviewMessage, }; From 0718d21941b57c697cc133da90d47b13ac61e76c Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 8 Nov 2023 17:45:57 +0100 Subject: [PATCH 2/7] fix: fix preview for splits --- src/libs/OptionsListUtils.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 5d5b5a7abda5..91b1a75511f3 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -393,14 +393,15 @@ function getReportPreviewMessageForOptionList(report, reportAction, isPreviewMes } const shouldShowWorkspaceName = ReportUtils.isExpenseReport(report) && isPreviewMessageForParentChatReport; + const actorID = report.managerID || reportAction.actorAccountID; const actor = ReportUtils.getActorNameForPreviewMessage({ report, shouldShowWorkspaceName, - actorID: reportAction.actorAccountID, + actorID, shouldUseShortForm: !isPreviewMessageForParentChatReport, }); - const shouldShowActorName = shouldShowWorkspaceName || isPreviewMessageForParentChatReport || currentUserAccountID !== reportAction.actorAccountID; - const actorDisplayName = shouldShowActorName ? `${actor}${isPreviewMessageForParentChatReport ? ' ' : ': '}` : ''; + const shouldShowActorName = shouldShowWorkspaceName || isPreviewMessageForParentChatReport || currentUserAccountID !== actorID; + const actorDisplayName = shouldShowActorName && actor ? `${actor}${isPreviewMessageForParentChatReport ? ' ' : ': '}` : ''; const message = ReportUtils.getReportPreviewMessage(report, reportAction, true, isPreviewMessageForParentChatReport, true); return `${actorDisplayName}${message}`; From 6aca1ddd46525d26ba9ae1330a755760b854ec60 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 8 Nov 2023 18:37:04 +0100 Subject: [PATCH 3/7] fix: get actor name for thread messages --- src/libs/OptionsListUtils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 91b1a75511f3..cffb54ac829b 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -449,7 +449,9 @@ function getLastMessageTextForReport(report) { ) { lastMessageTextFromReport = lodashGet(lastReportAction, 'message[0].text', ''); } else { - lastMessageTextFromReport = report ? report.lastMessageText || '' : ''; + const shouldShowLastActor = ReportUtils.isThread(report) && (ReportUtils.isExpenseReport(report) || ReportUtils.isIOUReport(report)) && currentUserAccountID !== report.lastActorAccountID; + const lastActorDisplayName = shouldShowLastActor ? `${ReportUtils.getDisplayNameForParticipant(report.lastActorAccountID, true)}: ` : ''; + lastMessageTextFromReport = report ? `${lastActorDisplayName}${report.lastMessageText}` : ''; // Yeah this is a bit ugly. If the latest report action that is not a whisper has been moderated as pending remove // then set the last message text to the text of the latest visible action that is not a whisper or the report creation message. From 888e2978547eb9b85945e537928f829c125fe1fe Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 8 Nov 2023 18:52:03 +0100 Subject: [PATCH 4/7] chore: run prettier --- src/libs/OptionsListUtils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index cffb54ac829b..8b8174f8ff8c 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -401,7 +401,7 @@ function getReportPreviewMessageForOptionList(report, reportAction, isPreviewMes shouldUseShortForm: !isPreviewMessageForParentChatReport, }); const shouldShowActorName = shouldShowWorkspaceName || isPreviewMessageForParentChatReport || currentUserAccountID !== actorID; - const actorDisplayName = shouldShowActorName && actor ? `${actor}${isPreviewMessageForParentChatReport ? ' ' : ': '}` : ''; + const actorDisplayName = shouldShowActorName && actor ? `${actor}${isPreviewMessageForParentChatReport ? ' ' : ': '}` : ''; const message = ReportUtils.getReportPreviewMessage(report, reportAction, true, isPreviewMessageForParentChatReport, true); return `${actorDisplayName}${message}`; @@ -449,7 +449,8 @@ function getLastMessageTextForReport(report) { ) { lastMessageTextFromReport = lodashGet(lastReportAction, 'message[0].text', ''); } else { - const shouldShowLastActor = ReportUtils.isThread(report) && (ReportUtils.isExpenseReport(report) || ReportUtils.isIOUReport(report)) && currentUserAccountID !== report.lastActorAccountID; + const shouldShowLastActor = + ReportUtils.isThread(report) && (ReportUtils.isExpenseReport(report) || ReportUtils.isIOUReport(report)) && currentUserAccountID !== report.lastActorAccountID; const lastActorDisplayName = shouldShowLastActor ? `${ReportUtils.getDisplayNameForParticipant(report.lastActorAccountID, true)}: ` : ''; lastMessageTextFromReport = report ? `${lastActorDisplayName}${report.lastMessageText}` : ''; From 01e355bd0ab9ad03d1a33dc7fcc38602a0fd14d6 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 9 Nov 2023 11:11:25 +0100 Subject: [PATCH 5/7] fix: apply requested changes --- src/libs/OptionsListUtils.js | 2 +- src/libs/ReportUtils.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 8b8174f8ff8c..18971722fcdf 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -377,7 +377,7 @@ function getAllReportErrors(report, reportActions) { * Get the preview message to be displayed in the option list. * @param {Object} report * @param {Object} reportAction - * @param {Boolean} isPreviewMessageForParentChatReport + * @param {Boolean} [isPreviewMessageForParentChatReport] * @returns {String} */ diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index f3961b6d724a..bd7988be88a5 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1790,8 +1790,8 @@ function getTransactionReportName(reportAction) { * * @param {Object} report * @param {Number} actorID - * @param {Boolean} shouldShowWorkspaceName - * @param {Boolean} shouldUseShortForm + * @param {Boolean} [shouldShowWorkspaceName] + * @param {Boolean} [shouldUseShortForm] * @returns {String} */ @@ -1805,8 +1805,8 @@ function getActorNameForPreviewMessage({report, actorID, shouldShowWorkspaceName * @param {Object} report * @param {Object} [reportAction={}] This can be either a report preview action or the IOU action * @param {Boolean} [shouldConsiderReceiptBeingScanned=false] - * @param {Boolean} isPreviewMessageForParentChatReport - * @param {Boolean} shouldHideParticipantName + * @param {Boolean} [isPreviewMessageForParentChatReport] + * @param {Boolean} [shouldHideParticipantName] * @returns {String} */ function getReportPreviewMessage(report, reportAction = {}, shouldConsiderReceiptBeingScanned = false, isPreviewMessageForParentChatReport = false, shouldHideParticipantName = false) { From 519c08c1e6442cc1cd2a3cc6c92d8b9744fd38b6 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 23 Nov 2023 10:26:35 +0100 Subject: [PATCH 6/7] fix: minor fix for displaying last actor --- src/libs/ReportUtils.js | 11 +++++++++-- src/libs/SidebarUtils.ts | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index c1f44785c5ca..6cb37b57a431 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1857,7 +1857,14 @@ function getActorNameForPreviewMessage({report, actorID, shouldShowWorkspaceName * @param {Object} [policy] * @returns {String} */ -function getReportPreviewMessage(report, reportAction = {}, shouldConsiderReceiptBeingScanned = false, isPreviewMessageForParentChatReport = false, shouldHideParticipantName = false, policy = undefined) { +function getReportPreviewMessage( + report, + reportAction = {}, + shouldConsiderReceiptBeingScanned = false, + isPreviewMessageForParentChatReport = false, + shouldHideParticipantName = false, + policy = undefined, +) { const reportActionMessage = lodashGet(reportAction, 'message[0].html', ''); if (_.isEmpty(report) || !report.reportID) { @@ -1886,7 +1893,7 @@ function getReportPreviewMessage(report, reportAction = {}, shouldConsiderReceip actorID: report.managerID, shouldUseShortForm: true, shouldShowWorkspaceName: isExpenseReport(report), - policy + policy, }); const payerName = shouldHideParticipantName ? '' : payerDisplayName; const formattedAmount = CurrencyUtils.convertToDisplayString(totalAmount, report.currency); diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 763a0000ba35..c3312ebebae9 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -406,7 +406,8 @@ function getOptionData( } : null; } - const lastActorDisplayName = hasMultipleParticipants && lastActorDetails?.accountID && Number(lastActorDetails.accountID) !== currentUserAccountID ? lastActorDetails.displayName : ''; + const lastActorDisplayName = + hasMultipleParticipants && lastActorDetails?.accountID && Number(lastActorDetails.accountID) !== currentUserAccountID ? lastActorDetails.displayName?.split(' ')[0] : ''; let lastMessageText = lastMessageTextFromReport; const reportAction = lastReportActions?.[report.reportID]; From 4e398e841b4e94c28ca856c157510c8968e67e0f Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Thu, 23 Nov 2023 14:09:35 +0100 Subject: [PATCH 7/7] fix: apply requested changes --- src/libs/OptionsListUtils.js | 4 ++-- src/libs/ReportUtils.js | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 860aa1a6b380..14bee6e79776 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -375,14 +375,14 @@ function getAllReportErrors(report, reportActions) { /** * Get the preview message to be displayed in the option list. + * * @param {Object} report * @param {Object} reportAction * @param {Boolean} [isPreviewMessageForParentChatReport] * @returns {String} */ - function getReportPreviewMessageForOptionList(report, reportAction, isPreviewMessageForParentChatReport = false) { - // for the request action preview we want to show the requestor instead of the user who owes the money + // For the request action preview we want to show the requestor instead of the user who owes the money if (!isPreviewMessageForParentChatReport && reportAction.originalMessage && reportAction.originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.CREATE) { const amount = Math.abs(reportAction.originalMessage.amount); const formattedAmount = CurrencyUtils.convertToDisplayString(amount, report.currency); diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 6cb37b57a431..3deed6ec6a70 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1838,10 +1838,9 @@ function getTransactionReportName(reportAction) { * @param {Number} actorID * @param {Boolean} [shouldShowWorkspaceName] * @param {Boolean} [shouldUseShortForm] - * @param {Object} [policy] - * @returns {String} + * @param {Object|undefined} [policy] + * @returns {String} */ - function getActorNameForPreviewMessage({report, actorID, shouldShowWorkspaceName = false, shouldUseShortForm = false, policy = undefined}) { return shouldShowWorkspaceName ? getPolicyName(report, false, policy) : getDisplayNameForParticipant(actorID, shouldUseShortForm); }