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

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

Closed
4 of 6 tasks
kavimuru opened this issue Jan 30, 2024 · 20 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review

Comments

@kavimuru
Copy link

kavimuru commented Jan 30, 2024

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
@kavimuru kavimuru added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jan 30, 2024
@melvin-bot melvin-bot bot 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 Jan 30, 2024
Copy link

melvin-bot bot commented Jan 30, 2024

Job added to Upwork: https://www.upwork.com/jobs/~0170b576c255476ae4

Copy link

melvin-bot bot commented Jan 30, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 30, 2024
Copy link

melvin-bot bot commented Jan 30, 2024

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

@paultsimura
Copy link
Contributor

paultsimura commented Jan 30, 2024

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) ?? '';

@tienifr
Copy link
Contributor

tienifr commented Jan 30, 2024

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.

@parasharrajat
Copy link
Member

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

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Jan 30, 2024

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

Copy link

melvin-bot bot commented Feb 2, 2024

@twisterdotcom, @parasharrajat, @grgia Whoops! This issue is 2 days overdue. Let's get this updated quick!

@twisterdotcom
Copy link
Contributor

@grgia just waiting on you to confirm

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 6, 2024
Copy link

melvin-bot bot commented Feb 6, 2024

📣 @tienifr 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Feb 6, 2024
@grgia
Copy link
Contributor

grgia commented Feb 6, 2024

@tienifr assigned!

@parasharrajat
Copy link
Member

PR reviewed.

@parasharrajat
Copy link
Member

PR deployed to PROD.

@tienifr
Copy link
Contributor

tienifr commented Mar 1, 2024

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

@twisterdotcom twisterdotcom 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 Mar 1, 2024
@twisterdotcom twisterdotcom added the Awaiting Payment Auto-added when associated PR is deployed to production label Mar 1, 2024
@twisterdotcom
Copy link
Contributor

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

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Mar 7, 2024
Copy link

melvin-bot bot commented Mar 14, 2024

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

@twisterdotcom
Copy link
Contributor

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

@twisterdotcom
Copy link
Contributor

Payment Summary:

@parasharrajat
Copy link
Member

Payment requested as per #35375 (comment)

@JmillsExpensify
Copy link

$500 approved for @parasharrajat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review
Projects
None yet
Development

No branches or pull requests

7 participants