Skip to content

[HOLD for payment 2023-10-09] [HOLD for payment 2023-09-29] [$500] Web - Inconsistency bug: App does not translate copy to clipboard text for requested (works fine for owes) #27114

Closed

Description

@kbecciv

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Open the app
  2. Click on plus and complete request money flow using any amount and any user
  3. Change language to spanish
  4. Open report to which we have requested money in step 2
  5. Copy IOU message of request money and paste anywhere to observe that it is translated correctly
  6. Click on IOU message and click on copy to clipboard on similar IOU message
  7. Paste and observe that it is not translated

Expected Result:

App should translate IOU message copy to clipboard text for 'requested' message as we do for similar IOU parent message

Actual Result:

App does not translate IOU message copy to clipboard text for 'requested' message IOU which we find on click of request money IOU in main report

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android / native
  • Android / Chrome
  • iOS / native
  • iOS / Safari
  • MacOS / Chrome / Safari
  • MacOS / Desktop

Version Number: 1.3.66.3
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos: Any additional supporting documentation

translation.copy.to.clipboard.for.inner.IOU.mp4
Recording.4371.mp4

Expensify/Expensify Issue URL:
Issue reported by: @dhanashree-sawant
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1693925728595269

View all open jobs on GitHub

Activity

  1. added
    ExternalAdded to denote the issue can be worked on by a contributor
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 10, 2023
  2. changed the title [-]Web - Inconsistency bug: App does not translate copy to clipboard text for requested (works fine for owes)[/-] [+][$500] Web - Inconsistency bug: App does not translate copy to clipboard text for requested (works fine for owes)[/+] on Sep 10, 2023
  3. melvin-bot commented on Sep 10, 2023

    @melvin-bot
  4. melvin-bot commented on Sep 10, 2023

    @melvin-bot

    Triggered auto assignment to @maddylewis (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  5. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 10, 2023
  6. melvin-bot commented on Sep 10, 2023

    @melvin-bot

    Bug0 Triage Checklist (Main S/O)

    • This "bug" occurs on a supported platform (ensure Platforms in OP are ✅)
    • This bug is not a duplicate report (check E/App issues and #expensify-bugs)
      • If it is, comment with a link to the original report, close the issue and add any novel details to the original issue instead
    • This bug is reproducible using the reproduction steps in the OP. S/O
      • If the reproduction steps are clear and you're unable to reproduce the bug, check with the reporter and QA first, then close the issue.
      • If the reproduction steps aren't clear and you determine the correct steps, please update the OP.
    • This issue is filled out as thoroughly and clearly as possible
      • Pay special attention to the title, results, platforms where the bug occurs, and if the bug happens on staging/production.
    • I have reviewed and subscribed to the linked Slack conversation to ensure Slack/Github stay in sync
  7. melvin-bot commented on Sep 10, 2023

    @melvin-bot

    Triggered auto assignment to @conorpendergrast (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

  8. melvin-bot commented on Sep 10, 2023

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @narefyev91 (External)

  9. getusha commented on Sep 10, 2023

    @getusha
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    copy clipboard text for requested is not translated according to preferences.

    What is the root cause of that problem?

    App/src/libs/ReportUtils.js

    Lines 2023 to 2040 in fd043aa

    switch (type) {
    case CONST.REPORT.ACTIONS.TYPE.APPROVED:
    iouMessage = `approved ${amount}`;
    break;
    case CONST.IOU.REPORT_ACTION_TYPE.CREATE:
    iouMessage = `requested ${amount}${comment && ` for ${comment}`}`;
    break;
    case CONST.IOU.REPORT_ACTION_TYPE.SPLIT:
    iouMessage = `split ${amount}${comment && ` for ${comment}`}`;
    break;
    case CONST.IOU.REPORT_ACTION_TYPE.DELETE:
    iouMessage = `deleted the ${amount} request${comment && ` for ${comment}`}`;
    break;
    case CONST.IOU.REPORT_ACTION_TYPE.PAY:
    iouMessage = isSettlingUp ? `paid ${amount}${paymentMethodMessage}` : `sent ${amount}${comment && ` for ${comment}`}${paymentMethodMessage}`;
    break;
    default:
    break;

    We have hard coded text which will not be translated dynamically depending on the user language selection.

    What changes do you think we should make in order to solve the problem?

    Such texts should be put inside en.js and es.js and should be used using Localize.translateLocal, for example we should move the following to en.js & es.js and make it a function to accept required arguments to use like payerOwesAmount

    iouMessage = `requested ${amount}${comment && ` for ${comment}`}`;

    Will be something like

    requestedAmount: ({amount, comment}) => `requested ${amount}${comment && ` for ${comment}`}`

    and will be used using the following

    Localize.translateLocal('iou.requestedAmount', {payer: comment, amount: formattedAmount})

    payerOwesAmount: ({payer, amount}: PayerOwesAmountParams) => `${payer} owes ${amount}`,

    What alternative solutions did you explore? (Optional)

  10. rayane-d commented on Sep 10, 2023

    @rayane-d
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    The problem we are addressing is that the app does not translate copy-to-clipboard text for requested money actions, although it works fine for IOUs.

    What is the root cause of that problem?

    The root cause of this issue lies in how we are retrieving and handling the copy-to-clipboard message in the context menu action located in the following here:

    {
    isAnonymousAction: true,
    textTranslateKey: 'reportActionContextMenu.copyToClipboard',
    icon: Expensicons.Copy,
    successTextTranslateKey: 'reportActionContextMenu.copied',
    successIcon: Expensicons.Checkmark,
    shouldShow: (type, reportAction) =>
    type === CONTEXT_MENU_TYPES.REPORT_ACTION &&
    !ReportUtils.isReportMessageAttachment(_.last(lodashGet(reportAction, ['message'], [{}]))) &&
    !ReportActionsUtils.isMessageDeleted(reportAction),
    // If return value is true, we switch the `text` and `icon` on
    // `ContextMenuItem` with `successText` and `successIcon` which will fallback to
    // the `text` and `icon`
    onPress: (closePopover, {reportAction, selection}) => {
    const isTaskAction = ReportActionsUtils.isTaskAction(reportAction);
    const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction);
    const message = _.last(lodashGet(reportAction, 'message', [{}]));
    const originalMessage = _.get(reportAction, 'originalMessage', {});
    const messageHtml = isTaskAction ? lodashGet(originalMessage, 'html', '') : lodashGet(message, 'html', '');
    const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message);
    if (!isAttachment) {
    const content = selection || messageHtml;
    if (isReportPreviewAction) {
    const iouReport = ReportUtils.getReport(ReportActionsUtils.getIOUReportIDFromReportActionPreview(reportAction));
    const displayMessage = ReportUtils.getReportPreviewMessage(iouReport, reportAction);
    Clipboard.setString(displayMessage);
    } else if (ReportActionsUtils.isModifiedExpenseAction(reportAction)) {
    const modifyExpenseMessage = ReportUtils.getModifiedExpenseMessage(reportAction);
    Clipboard.setString(modifyExpenseMessage);
    } else if (content) {
    const parser = new ExpensiMark();
    if (!Clipboard.canSetHtml()) {
    Clipboard.setString(parser.htmlToMarkdown(content));
    } else {
    const plainText = parser.htmlToText(content);
    Clipboard.setHtml(content, plainText);
    }
    }
    } else {
    Clipboard.setString(messageHtml);
    }
    if (closePopover) {
    hideContextMenu(true, ReportActionComposeFocusManager.focus);
    }
    },
    getDescription: () => {},
    },

    In the case of IOUs (user owes amount), the message is properly translated:
    we are getting %user% owes %amount% message here:

    if (isReportPreviewAction) {
    const iouReport = ReportUtils.getReport(ReportActionsUtils.getIOUReportIDFromReportActionPreview(reportAction));
    const displayMessage = ReportUtils.getReportPreviewMessage(iouReport, reportAction);
    Clipboard.setString(displayMessage);

    In the language file, the translation is defined as follows:

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

    payerOwesAmount: ({payer, amount}: PayerOwesAmountParams) => `${payer} owes ${amount}`,

    However, for requested money actions in the format requested %currency% %amount% for %comment% we are obtaining the message directly from the Onyx data here:

    } else if (content) {
    const parser = new ExpensiMark();
    if (!Clipboard.canSetHtml()) {
    Clipboard.setString(parser.htmlToMarkdown(content));
    } else {
    const plainText = parser.htmlToText(content);
    Clipboard.setHtml(content, plainText);
    }
    }

    What changes do you think we should make in order to solve the problem?

    To resolve this issue, we should modify the copy-to-clipboard context menu action here to include a case for money request actions. We should extract the amount and currency of the request from the Onyx data and create the translated message in the format:
    requested %currency% %amount% for %comment% using Localize.translateLocal
    Here's the proposed code change:

    else if (ReportActionsUtils.isMoneyRequestAction(reportAction)) {
        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);
    }

    Additionally, we need to add the translation for this message in the language files (e.g., en.ts and Spanish).

    In the translation file (en.ts), add the following translation:

    requestedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `requested ${formattedAmount}${comment ? ` for ${comment}` : ''}`,

    Ensure that a similar translation is added for the Spanish language.

    requestedAmount: ({formattedAmount, comment}: RequestedAmountMessageParams) => `solicité ${formattedAmount}${comment ? ` para ${comment}` : ''}`,

    By making these code changes and adding translations, we will be able to properly translate and copy-to-clipboard the requested money action messages.

    What alternative solutions did you explore? (Optional)

  11. 66 remaining items

  12. maddylewis commented on Oct 12, 2023

    @maddylewis
    Contributor

    yes! i will process payments / post an updated payment summary before EOD!

  13. rayane-d commented on Oct 12, 2023

    @rayane-d
    Contributor

    Friendly reminder @maddylewis

  14. maddylewis commented on Oct 13, 2023

    @maddylewis
    Contributor

    Payments

    Contributor hired on 9/11. PR merged on 9/26.

  15. maddylewis commented on Oct 13, 2023

    @maddylewis
    Contributor

    @narefyev91 - will you please review/fill out this checklist when you have a chance? thanks! #27114 (comment)

  16. maddylewis commented on Oct 13, 2023

    @maddylewis
    Contributor
  17. rayane-d commented on Oct 13, 2023

    @rayane-d
    Contributor

    Offer accepted @maddylewis

  18. JmillsExpensify commented on Oct 13, 2023

    @JmillsExpensify
    Contributor

    $500 payment approved for @mananjadhav based on BZ summary.

  19. narefyev91 commented on Oct 16, 2023

    @narefyev91
    Contributor
    • The PR that introduced the bug has been identified. Link to the PR - current PR is more for missing functionality rather than regression fix
    • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment - N/A
    • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion - N/A
    • Determine if we should create a regression test for this bug - N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions