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 Copying Sent Money Report Action text copies a wrong text #27889

41 changes: 33 additions & 8 deletions src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,39 @@ 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);
const displaymessage = Localize.translateLocal('iou.requestedAmount', {
formattedAmount,
comment,
});
Clipboard.setString(displaymessage);
let displayMessage;
if (originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we can move all logic from if to some util function and return here just displayMessage
getTaskReportActionMessage for reference

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,
});
}
Clipboard.setString(displayMessage);
} else if (content) {
const parser = new ExpensiMark();
if (!Clipboard.canSetHtml()) {
Expand Down
Loading