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

[$500] IOU - A "-" sign appears in front of the currency in the Distance IOU preview #33489

Closed
6 tasks done
izarutskaya opened this issue Dec 22, 2023 · 13 comments
Closed
6 tasks done
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@izarutskaya
Copy link

izarutskaya commented Dec 22, 2023

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 1.4.15-1
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
Expensify/Expensify Issue URL:
Issue reported by: Applause-Internal Team
Slack conversation: @

Action Performed:

  1. Open New Expensify app
  2. Log into the HT account
  3. Create a WS if you don't already have one.
  4. Send a distanсe IOU(with any correct data) to WS
  5. Navigate to Report Conversation
  6. If the problem does not occur the first time, repeat step №4 several times.

Expected Result:

No unnecessary characters should appear in the preview of the distance IOU

Actual Result:

When creating a Remote IOU, before the map is loaded in the preview, a "-" appears in front of the currency

Workaround:

Unknown

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

Bug6323686_1703233040730.Recording__963.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~019f65c5024fc15f72
  • Upwork Job ID: 1738136877882548224
  • Last Price Increase: 2023-12-29
@izarutskaya izarutskaya 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 Dec 22, 2023
@melvin-bot melvin-bot bot changed the title IOU - A "-" sign appears in front of the currency in the Distance IOU preview [$500] IOU - A "-" sign appears in front of the currency in the Distance IOU preview Dec 22, 2023
Copy link

melvin-bot bot commented Dec 22, 2023

Job added to Upwork: https://www.upwork.com/jobs/~019f65c5024fc15f72

Copy link

melvin-bot bot commented Dec 22, 2023

Triggered auto assignment to @anmurali (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 Dec 22, 2023
Copy link

melvin-bot bot commented Dec 22, 2023

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

Copy link

melvin-bot bot commented Dec 22, 2023

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

@bernhardoj
Copy link
Contributor

bernhardoj commented Dec 22, 2023

Proposal

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

When creating a new distance request, we can see the amount is negative.

What is the root cause of that problem?

When creating a new distance request, we optimistically create a new transaction with a negative amount.

App/src/libs/actions/IOU.js

Lines 656 to 657 in 862b0ea

let optimisticTransaction = TransactionUtils.buildOptimisticTransaction(
ReportUtils.isExpenseReport(iouReport) ? -amount : amount,

Then, the amount shown will be negated and we should see a positive value.

// Expense report case:
// The amounts are stored using an opposite sign and negative values can be set,
// we need to return an opposite sign than is saved in the transaction object
let amount = transaction?.modifiedAmount ?? 0;
if (amount) {
return -amount;
}
// To avoid -0 being shown, lets only change the sign if the value is other than 0.
amount = transaction?.amount ?? 0;
return amount ? -amount : 0;

However, every time we create a new request, we merge the optimistic transaction with the negative amount with the transaction draft that always has a positive amount.

App/src/libs/actions/IOU.js

Lines 682 to 688 in 862b0ea

const existingTransaction = allTransactionDrafts[`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${CONST.IOU.OPTIMISTIC_TRANSACTION_ID}`];
if (existingTransaction && existingTransaction.iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE) {
optimisticTransaction = {
...optimisticTransaction,
...existingTransaction,
transactionID: optimisticTransaction.transactionID,
};

That's why we see the negative amount.

(this is the regression from #32943)

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

Prevent the optimistic amount from being overwritten by the draft amount.

We can set the amount specifically to be the optimistic amount.

amount: optimisticTransaction.amount,

(or just omit it from the draft transaction)

What alternative solutions did you explore? (Optional)

Instead of merging all data from the draft transaction, we could just pick some data that is missing from the optimistic transaction, such as waypoints, comment.type, and comment.customUnit (but we will need to init both type and customUnit as explained here).

@melvin-bot melvin-bot bot added the Overdue label Dec 25, 2023
Copy link

melvin-bot bot commented Dec 25, 2023

@ntdiary, @anmurali Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@tienifr
Copy link
Contributor

tienifr commented Dec 25, 2023

Proposal

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

When creating a Remote IOU, before the map is loaded in the preview, a "-" appears in front of the currency

What is the root cause of that problem?

In here, the amount of existingTransaction which is positive, overrides the negative amount set in optimisticTransaction. The amount is display with opposite sign here for expense report case so it ends up showing as negative.

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

The transaction amount might be stored as negative, but it's only for back-end tracking purpose so we shouldn't convert the signs around in client side.

We should:

  1. Modify this so that so that it returns Math.abs of the modifiedAmount or amount even for expense report case, similar to what we already did for IOU report here.
  2. Remove the logic where we negate the amount if it's expense report, for example in here, and just use the original positive amount.

With these changes, we eradicate the confusing negating logic in the codebase while still have the proper displaying logic where if the back-end stores it as negative for tracking purpose, we'll still show it correctly as positive in client side. This is similar to what's already done for IOU requests.

What alternative solutions did you explore? (Optional)

NA

Copy link

melvin-bot bot commented Dec 27, 2023

@ntdiary, @anmurali Huh... This is 4 days overdue. Who can take care of this?

Copy link

melvin-bot bot commented Dec 29, 2023

@ntdiary, @anmurali 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

Copy link

melvin-bot bot commented Dec 29, 2023

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@mvtglobally
Copy link

Issue not reproducible during KI retests. (First week)

Copy link

melvin-bot bot commented Jan 2, 2024

@ntdiary, @anmurali 10 days overdue. I'm getting more depressed than Marvin.

@anmurali
Copy link

anmurali commented Jan 2, 2024

Closed, cannot reproduce

@anmurali anmurali closed this as completed Jan 2, 2024
@melvin-bot melvin-bot bot removed the Overdue label Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
None yet
Development

No branches or pull requests

6 participants