Skip to content

[HOLD for payment 2024-03-06] [$500] Copy to clipboard on the system message for paid expense copies negative amount #35375

Closed

Description

@kavimuru

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


Version Number: 1.4.33-0
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4211589
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: Applause internal team
Slack conversation:

Action Performed:

  1. Open https://staging.new.expensify.com/
  2. Log in under your HT account - A
  3. Send an IOU with any amount to Account B that you have access to
  4. Log in under account B
  5. Navigate to the conversation with account A
  6. Open IOU Report Conversation
  7. Turn off the internet
  8. Pay for the IOU
  9. Copy the system payment message "paid {currency} {amount} elsewhere"
  10. Paste the copied message into the Compose Box

Expected Result:

The system message must be copied without the "-" sign in front of the currency

Actual Result:

Copy to clipboard on the system message for paid expense copies negative amount

Workaround:

Can the user still use Expensify without this being fixed? Have you informed them of the workaround?

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6360699_1706609460840.Recording__1214.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0170b576c255476ae4
  • Upwork Job ID: 1752283071992983552
  • Last Price Increase: 2024-01-30
  • Automatic offers:
    • tienifr | Contributor | 28145024

Activity

  1. added
    External
    Daily
    Bug
    on Jan 30, 2024
  2. changed the title [-]Copy to clipboard on the system message for paid expense copies negative amount[/-] [+][$500] Copy to clipboard on the system message for paid expense copies negative amount[/+] on Jan 30, 2024
  3. melvin-bot commented on Jan 30, 2024

    @melvin-bot
  4. melvin-bot commented on Jan 30, 2024

    @melvin-bot

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

  5. added
    Help Wanted
    on Jan 30, 2024
  6. melvin-bot commented on Jan 30, 2024

    @melvin-bot

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

  7. paultsimura commented on Jan 30, 2024

    @paultsimura
    Contributor

    Proposal

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

    Copied "paid" report action contains a negative amount

    What is the root cause of that problem?

    Since the Paid action means the user pays money, not receives it, the IOU amount is set with a negative value in the originalMessage.IOUDetails. We do not negate this value when copying the message to clipboard:

    App/src/libs/ReportUtils.ts

    Lines 4377 to 4398 in 480ae8d

    if (originalMessage.type === CONST.IOU.REPORT_ACTION_TYPE.PAY) {
    // The `REPORT_ACTION_TYPE.PAY` action type is used for both fulfilling existing requests and sending money. To
    // differentiate between these two scenarios, we check if the `originalMessage` contains the `IOUDetails`
    // property. If it does, it indicates that this is a 'Send money' action.
    const {amount, currency} = originalMessage.IOUDetails ?? originalMessage;
    const formattedAmount = CurrencyUtils.convertToDisplayString(amount, currency) ?? '';
    const payerName = isExpenseReport(iouReport) ? getPolicyName(iouReport) : getDisplayNameForParticipant(iouReport?.managerID, true);
    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.paidWithExpensifyWithAmount';
    break;
    default:
    translationKey = 'iou.payerPaidAmount';
    break;
    }
    return Localize.translateLocal(translationKey, {amount: formattedAmount, payer: payerName ?? ''});
    }

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

    When building an optimistic Paid report action, we should set the same amount value as it comes from the BE.
    We should use iouReport.total, not -iouReport.total:

    App/src/libs/actions/IOU.js

    Lines 3089 to 3099 in 6198343

    const optimisticIOUReportAction = ReportUtils.buildOptimisticIOUReportAction(
    CONST.IOU.REPORT_ACTION_TYPE.PAY,
    -iouReport.total,
    iouReport.currency,
    '',
    [recipient],
    '',
    paymentMethodType,
    iouReport.reportID,
    true,
    );

    What alternative solutions did you explore? (Optional)

    When building the getIOUReportActionDisplayMessage, use Math.abs(amount) instead of amount:

    const formattedAmount = CurrencyUtils.convertToDisplayString(Math.abs(amount), currency) ?? '';
  8. tienifr commented on Jan 30, 2024

    @tienifr
    Contributor

    Proposal

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

    Copy to clipboard on the system message for paid expense copies negative amount

    What is the root cause of that problem?

    In here, when generating optimistic data for the pay money request, we're always negating the amount (-iouReport.total)

    This is wrong because the amount will only be stored as negative for the Workspace expense report, for other IOUs, it will be positive, more context here (and a lot of other places).

    If we go online, this problem no longer happens because the data from back-end is correct (positive)

    So the root cause is the optimistic data of the amount in normal IOU case is wrong.

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

    In here, only negate the total amount if the iouReport is a workspace expense.

    ReportUtils.isExpenseReport(iouReport) ? -iouReport.total : iouReport.total
    

    Simply changing to iouReport.total will reintroduce the same problem for expense report that was fixed here (it used to be iouReport.total without sign before that PR), because iouReport.total is negative for expense report.

    What alternative solutions did you explore? (Optional)

    Using Math.abs( here is also ok.

  9. parasharrajat commented on Jan 30, 2024

    @parasharrajat
    Member

    @tienifr proposal's main solution makes sense. Good point on catching the Expense Report case.

    🎀 👀 🎀 C+ reviewed

  10. melvin-bot commented on Jan 30, 2024

    @melvin-bot

    Triggered auto assignment to @grgia, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

  11. 12 remaining items

  12. parasharrajat commented on Feb 20, 2024

    @parasharrajat
    Member

    PR reviewed.

  13. parasharrajat commented on Feb 29, 2024

    @parasharrajat
    Member

    PR deployed to PROD.

  14. tienifr commented on Mar 1, 2024

    @tienifr
    Contributor

    @twisterdotcom PR hit production. Melvin is malfunctioning. Please add HOLD for payment label.

  15. changed the title [-][$500] Copy to clipboard on the system message for paid expense copies negative amount[/-] [+][HOLD for payment 2024-03-06] [$500] Copy to clipboard on the system message for paid expense copies negative amount[/+] on Mar 1, 2024
  16. added
    Awaiting Payment
    on Mar 1, 2024
  17. twisterdotcom commented on Mar 1, 2024

    @twisterdotcom
    Contributor

    Eugh, no Melvin comments either. 😭 Why do you make me do work Melvin.

  18. added
    Daily
    and removed
    Weekly
    on Mar 7, 2024
  19. melvin-bot commented on Mar 14, 2024

    @melvin-bot

    @twisterdotcom, @parasharrajat, @grgia, @tienifr Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

  20. twisterdotcom commented on Mar 15, 2024

    @twisterdotcom
    Contributor

    Wow, I need to pay this. Sorry for the tardiness.

  21. twisterdotcom commented on Mar 15, 2024

    @twisterdotcom
    Contributor

    Payment Summary:

  22. parasharrajat commented on May 20, 2024

    @parasharrajat
    Member

    Payment requested as per #35375 (comment)

  23. JmillsExpensify commented on May 31, 2024

    @JmillsExpensify
    Contributor

    $500 approved for @parasharrajat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternalReviewing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions