From eda02a0807499330fb3b5015000f3ecef8dafc63 Mon Sep 17 00:00:00 2001 From: Rayane Djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Wed, 20 Sep 2023 19:52:55 +0000 Subject: [PATCH 1/8] Fix Copying Sent Money Report Action text copies the wrong text --- .../report/ContextMenu/ContextMenuActions.js | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 173bda0e5221..8abfe2555019 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -207,11 +207,34 @@ export default [ const transaction = TransactionUtils.getTransaction(originalMessage.IOUTransactionID); const {amount, currency, comment} = ReportUtils.getTransactionDetails(transaction); const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency); - const displaymessage = Localize.translateLocal('iou.requestedAmount', { - formattedAmount, - comment, - }); - Clipboard.setString(displaymessage); + let displayMessage; + if (ReportActionsUtils.isSentMoneyReportAction(reportAction)) { + const iouReport = ReportUtils.getReport(originalMessage.IOUReportID); + const payerName = ReportUtils.getDisplayNameForParticipant(iouReport.managerID, true); + let translationKey; + switch (originalMessage.paymentType) { + case CONST.IOU.PAYMENT_TYPE.ELSEWHERE: + translationKey = 'iou.paidElsewhereWithAmount'; + break; + case CONST.IOU.PAYMENT_TYPE.PAYPAL_ME: + translationKey = 'iou.paidUsingPaypalWithAmount'; + break; + case CONST.IOU.PAYMENT_TYPE.EXPENSIFY: + case CONST.IOU.PAYMENT_TYPE.VBBA: + translationKey = 'iou.paidUsingExpensifyWithAmount'; + break; + default: + translationKey = ''; + break; + } + displayMessage = Localize.translateLocal(translationKey, {amount: formattedAmount, payer: payerName}); + } else { + displayMessage = Localize.translateLocal('iou.requestedAmount', { + formattedAmount, + comment, + }); + } + Clipboard.setString(displayMessage); } else if (content) { const parser = new ExpensiMark(); if (!Clipboard.canSetHtml()) { From 540dfa154de61ab9421d6fc0c0a3089d2b5ae2ff Mon Sep 17 00:00:00 2001 From: Rayane Djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Wed, 20 Sep 2023 21:05:43 +0000 Subject: [PATCH 2/8] Fix Copying Sent Money Report Action text copies the wrong text --- .../home/report/ContextMenu/ContextMenuActions.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 8abfe2555019..d965fe457d76 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -204,13 +204,12 @@ export default [ Clipboard.setString(modifyExpenseMessage); } else if (ReportActionsUtils.isMoneyRequestAction(reportAction)) { const originalMessage = _.get(reportAction, 'originalMessage', {}); - const transaction = TransactionUtils.getTransaction(originalMessage.IOUTransactionID); - const {amount, currency, comment} = ReportUtils.getTransactionDetails(transaction); - const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency); let displayMessage; if (ReportActionsUtils.isSentMoneyReportAction(reportAction)) { - const iouReport = ReportUtils.getReport(originalMessage.IOUReportID); - const payerName = ReportUtils.getDisplayNameForParticipant(iouReport.managerID, true); + const {amount, currency, IOUReportID} = originalMessage; + const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency); + const iouReport = ReportUtils.getReport(IOUReportID); + const payerName = ReportActionsUtils.getDisplayNameForParticipant(iouReport.managerID, true); let translationKey; switch (originalMessage.paymentType) { case CONST.IOU.PAYMENT_TYPE.ELSEWHERE: @@ -229,6 +228,9 @@ export default [ } displayMessage = Localize.translateLocal(translationKey, {amount: formattedAmount, payer: payerName}); } else { + const transaction = TransactionUtils.getTransaction(originalMessage.IOUTransactionID); + const {amount, currency, comment} = ReportUtils.getTransactionDetails(transaction); + const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency); displayMessage = Localize.translateLocal('iou.requestedAmount', { formattedAmount, comment, From 0167ae13c1d1d5fa6fe6cf6c852e400e14ec3877 Mon Sep 17 00:00:00 2001 From: Rayane Djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Wed, 20 Sep 2023 21:25:53 +0000 Subject: [PATCH 3/8] using getDisplayNameForParticipant function lib from ReportUtils instead of ReportActionsUtils --- src/pages/home/report/ContextMenu/ContextMenuActions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index d965fe457d76..9ee801fbd4a6 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -205,11 +205,11 @@ export default [ } else if (ReportActionsUtils.isMoneyRequestAction(reportAction)) { const originalMessage = _.get(reportAction, 'originalMessage', {}); let displayMessage; - if (ReportActionsUtils.isSentMoneyReportAction(reportAction)) { + if (originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) { const {amount, currency, IOUReportID} = originalMessage; const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency); const iouReport = ReportUtils.getReport(IOUReportID); - const payerName = ReportActionsUtils.getDisplayNameForParticipant(iouReport.managerID, true); + const payerName = ReportUtils.getDisplayNameForParticipant(iouReport.managerID, true); let translationKey; switch (originalMessage.paymentType) { case CONST.IOU.PAYMENT_TYPE.ELSEWHERE: From 6f3221da0284f148e3d8d8354fee78614e7c6472 Mon Sep 17 00:00:00 2001 From: Rayane Djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Thu, 21 Sep 2023 17:36:32 +0000 Subject: [PATCH 4/8] Fix Copying IOU Report Action text copies a wrong text --- src/libs/ReportUtils.js | 46 ++++++++++++++++++- .../report/ContextMenu/ContextMenuActions.js | 37 +-------------- 2 files changed, 46 insertions(+), 37 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 7916630d7b4e..cbd41816af09 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -557,7 +557,7 @@ function findLastAccessedReport(reports, ignoreDomainRooms, policies, isFirstTim if (ignoreDomainRooms) { // We allow public announce rooms, admins, and announce rooms through since we bypass the default rooms beta for them. - // Check where ReportUtils.findLastAccessedReport is called in MainDrawerNavigator.js for more context. + // Check where findLastAccessedReport is called in MainDrawerNavigator.js for more context. // Domain rooms are now the only type of default room that are on the defaultRooms beta. sortedReports = _.filter( sortedReports, @@ -3517,6 +3517,49 @@ function getReportPreviewDisplayTransactions(reportPreviewAction) { ); } +/** + * Return iou report action display message + * + * @param {Object} reportAction report action + * @returns {String} + */ +function getIouReportActionDisplayMessage(reportAction) { + const originalMessage = _.get(reportAction, 'originalMessage', {}); + let displayMessage; + if (originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) { + const {amount, currency, IOUReportID} = originalMessage; + const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency); + const iouReport = getReport(IOUReportID); + const payerName = isExpenseReport(iouReport) ? getPolicyName(iouReport, false, getPolicyName(iouReport)) : getDisplayNameForParticipant(iouReport.managerID); + let translationKey; + switch (originalMessage.paymentType) { + case CONST.IOU.PAYMENT_TYPE.ELSEWHERE: + translationKey = 'iou.paidElsewhereWithAmount'; + break; + case CONST.IOU.PAYMENT_TYPE.PAYPAL_ME: + translationKey = 'iou.paidUsingPaypalWithAmount'; + break; + case CONST.IOU.PAYMENT_TYPE.EXPENSIFY: + case CONST.IOU.PAYMENT_TYPE.VBBA: + translationKey = 'iou.paidUsingExpensifyWithAmount'; + break; + default: + translationKey = ''; + break; + } + displayMessage = Localize.translateLocal(translationKey, {amount: formattedAmount, payer: payerName}); + } else { + const transaction = TransactionUtils.getTransaction(originalMessage.IOUTransactionID); + const {amount, currency, comment} = getTransactionDetails(transaction); + const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency); + displayMessage = Localize.translateLocal('iou.requestedAmount', { + formattedAmount, + comment, + }); + } + return displayMessage; +} + export { getReportParticipantsTitle, isReportMessageAttachment, @@ -3657,4 +3700,5 @@ export { getReportPreviewDisplayTransactions, getTransactionsWithReceipts, hasMissingSmartscanFields, + getIouReportActionDisplayMessage, }; diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 9ee801fbd4a6..eafc0e03bc9b 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -22,9 +22,6 @@ import MiniQuickEmojiReactions from '../../../../components/Reactions/MiniQuickE import Navigation from '../../../../libs/Navigation/Navigation'; import ROUTES from '../../../../ROUTES'; import * as Task from '../../../../libs/actions/Task'; -import * as Localize from '../../../../libs/Localize'; -import * as TransactionUtils from '../../../../libs/TransactionUtils'; -import * as CurrencyUtils from '../../../../libs/CurrencyUtils'; /** * Gets the HTML version of the message in an action. @@ -203,39 +200,7 @@ export default [ const modifyExpenseMessage = ReportUtils.getModifiedExpenseMessage(reportAction); Clipboard.setString(modifyExpenseMessage); } else if (ReportActionsUtils.isMoneyRequestAction(reportAction)) { - const originalMessage = _.get(reportAction, 'originalMessage', {}); - let displayMessage; - if (originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) { - const {amount, currency, IOUReportID} = originalMessage; - const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency); - const iouReport = ReportUtils.getReport(IOUReportID); - const payerName = ReportUtils.getDisplayNameForParticipant(iouReport.managerID, true); - let translationKey; - switch (originalMessage.paymentType) { - case CONST.IOU.PAYMENT_TYPE.ELSEWHERE: - translationKey = 'iou.paidElsewhereWithAmount'; - break; - case CONST.IOU.PAYMENT_TYPE.PAYPAL_ME: - translationKey = 'iou.paidUsingPaypalWithAmount'; - break; - case CONST.IOU.PAYMENT_TYPE.EXPENSIFY: - case CONST.IOU.PAYMENT_TYPE.VBBA: - translationKey = 'iou.paidUsingExpensifyWithAmount'; - break; - default: - translationKey = ''; - break; - } - displayMessage = Localize.translateLocal(translationKey, {amount: formattedAmount, payer: payerName}); - } else { - const transaction = TransactionUtils.getTransaction(originalMessage.IOUTransactionID); - const {amount, currency, comment} = ReportUtils.getTransactionDetails(transaction); - const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency); - displayMessage = Localize.translateLocal('iou.requestedAmount', { - formattedAmount, - comment, - }); - } + const displayMessage = ReportUtils.getIouReportActionDisplayMessage(reportAction); Clipboard.setString(displayMessage); } else if (content) { const parser = new ExpensiMark(); From 4c9641df241afb970b5d142bae214c1f5f999712 Mon Sep 17 00:00:00 2001 From: Rayane Djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Thu, 21 Sep 2023 17:44:13 +0000 Subject: [PATCH 5/8] correct comment --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index cbd41816af09..82cd9047654c 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -557,7 +557,7 @@ function findLastAccessedReport(reports, ignoreDomainRooms, policies, isFirstTim if (ignoreDomainRooms) { // We allow public announce rooms, admins, and announce rooms through since we bypass the default rooms beta for them. - // Check where findLastAccessedReport is called in MainDrawerNavigator.js for more context. + // Check where ReportUtils.findLastAccessedReport is called in MainDrawerNavigator.js for more context. // Domain rooms are now the only type of default room that are on the defaultRooms beta. sortedReports = _.filter( sortedReports, From b0bdad61d495840f8ef683b0add4eb8d6527f499 Mon Sep 17 00:00:00 2001 From: Rayane Djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Fri, 22 Sep 2023 13:50:18 +0000 Subject: [PATCH 6/8] remove paypal paymentType --- src/libs/ReportUtils.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 0f4b1882e901..4b7acd121d0b 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -3611,9 +3611,6 @@ function getIouReportActionDisplayMessage(reportAction) { case CONST.IOU.PAYMENT_TYPE.ELSEWHERE: translationKey = 'iou.paidElsewhereWithAmount'; break; - case CONST.IOU.PAYMENT_TYPE.PAYPAL_ME: - translationKey = 'iou.paidUsingPaypalWithAmount'; - break; case CONST.IOU.PAYMENT_TYPE.EXPENSIFY: case CONST.IOU.PAYMENT_TYPE.VBBA: translationKey = 'iou.paidUsingExpensifyWithAmount'; From 0deecc606ab79f182e09b4a2c598a5f90d54e235 Mon Sep 17 00:00:00 2001 From: Rayane Djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Fri, 22 Sep 2023 14:46:26 +0000 Subject: [PATCH 7/8] fix payer name --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 4b7acd121d0b..dd5007b61af5 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -3605,7 +3605,7 @@ function getIouReportActionDisplayMessage(reportAction) { const {amount, currency, IOUReportID} = originalMessage; const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency); const iouReport = getReport(IOUReportID); - const payerName = isExpenseReport(iouReport) ? getPolicyName(iouReport, false, getPolicyName(iouReport)) : getDisplayNameForParticipant(iouReport.managerID); + const payerName = isExpenseReport(iouReport) ? getPolicyName(iouReport) : getDisplayNameForParticipant(iouReport.managerID); let translationKey; switch (originalMessage.paymentType) { case CONST.IOU.PAYMENT_TYPE.ELSEWHERE: From d3afa28f60ed868947162f35851b90068ccc54c2 Mon Sep 17 00:00:00 2001 From: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> Date: Mon, 25 Sep 2023 17:54:05 +0200 Subject: [PATCH 8/8] rename getIOUReportActionDisplayMessage method --- src/libs/ReportUtils.js | 4 ++-- src/pages/home/report/ContextMenu/ContextMenuActions.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index dd5007b61af5..e04f49e06070 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -3598,7 +3598,7 @@ function getReportPreviewDisplayTransactions(reportPreviewAction) { * @param {Object} reportAction report action * @returns {String} */ -function getIouReportActionDisplayMessage(reportAction) { +function getIOUReportActionDisplayMessage(reportAction) { const originalMessage = _.get(reportAction, 'originalMessage', {}); let displayMessage; if (originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) { @@ -3773,5 +3773,5 @@ export { getReportPreviewDisplayTransactions, getTransactionsWithReceipts, hasMissingSmartscanFields, - getIouReportActionDisplayMessage, + getIOUReportActionDisplayMessage, }; diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index eafc0e03bc9b..64b7d39ed975 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -200,7 +200,7 @@ export default [ const modifyExpenseMessage = ReportUtils.getModifiedExpenseMessage(reportAction); Clipboard.setString(modifyExpenseMessage); } else if (ReportActionsUtils.isMoneyRequestAction(reportAction)) { - const displayMessage = ReportUtils.getIouReportActionDisplayMessage(reportAction); + const displayMessage = ReportUtils.getIOUReportActionDisplayMessage(reportAction); Clipboard.setString(displayMessage); } else if (content) { const parser = new ExpensiMark();