Skip to content

Commit

Permalink
Merge pull request #27889 from rayane-djouah/fix-app-does-not-transla…
Browse files Browse the repository at this point in the history
…te-copy-to-clipboard-text-for-requested

Fix Copying Sent Money Report Action text copies a wrong text
  • Loading branch information
mountiny authored Sep 26, 2023
2 parents 3486648 + 1a07991 commit 0477b33
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 12 deletions.
41 changes: 41 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3625,6 +3625,46 @@ 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) : getDisplayNameForParticipant(iouReport.managerID);
let translationKey;
switch (originalMessage.paymentType) {
case CONST.IOU.PAYMENT_TYPE.ELSEWHERE:
translationKey = 'iou.paidElsewhereWithAmount';
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,
Expand Down Expand Up @@ -3765,5 +3805,6 @@ export {
getReportPreviewDisplayTransactions,
getTransactionsWithReceipts,
hasMissingSmartscanFields,
getIOUReportActionDisplayMessage,
isWaitingForTaskCompleteFromAssignee,
};
14 changes: 2 additions & 12 deletions src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -203,15 +200,8 @@ export default [
const modifyExpenseMessage = ReportUtils.getModifiedExpenseMessage(reportAction);
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);
const displaymessage = Localize.translateLocal('iou.requestedAmount', {
formattedAmount,
comment,
});
Clipboard.setString(displaymessage);
const displayMessage = ReportUtils.getIOUReportActionDisplayMessage(reportAction);
Clipboard.setString(displayMessage);
} else if (content) {
const parser = new ExpensiMark();
if (!Clipboard.canSetHtml()) {
Expand Down

0 comments on commit 0477b33

Please sign in to comment.