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-07-10] [$250] Search - Total amount for the report in Shared is -0.00 when it has only scanning expenses #43990

Closed
6 tasks done
izarutskaya opened this issue Jun 19, 2024 · 25 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

Comments

@izarutskaya
Copy link

izarutskaya commented Jun 19, 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.85-6
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/4609426
Logs: https://stackoverflow.com/c/expensify/questions/4856
Issue reported by: Applause-Internal team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Create a new workspace.
  3. Submit two scan expenses to the workspace chat.
  4. While the scanning is ongoing, go to Search.
  5. Go to Shared.

Expected Result:

The total amount for the report in Shared will be 0.00.

Actual Result:

The total amount for the report in Shared is -0.00.

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

20240619_171945.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0122d04513e0a42253
  • Upwork Job ID: 1803626666039149098
  • Last Price Increase: 2024-06-20
  • Automatic offers:
    • c3024 | Reviewer | 102824702
    • nkdengineer | Contributor | 102824703
Issue OwnerCurrent Issue Owner: @mallenexpensify
@izarutskaya izarutskaya added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 19, 2024
Copy link

melvin-bot bot commented Jun 19, 2024

Triggered auto assignment to @mallenexpensify (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@izarutskaya
Copy link
Author

We think this issue might be related to the #collect project.

@mallenexpensify mallenexpensify added Internal Requires API changes or must be handled by Expensify staff External Added to denote the issue can be worked on by a contributor and removed Internal Requires API changes or must be handled by Expensify staff labels Jun 20, 2024
Copy link

melvin-bot bot commented Jun 20, 2024

Job added to Upwork: https://www.upwork.com/jobs/~0122d04513e0a42253

@melvin-bot melvin-bot bot changed the title Search - Total amount for the report in Shared is -0.00 when it has only scanning expenses [$250] Search - Total amount for the report in Shared is -0.00 when it has only scanning expenses Jun 20, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 20, 2024
Copy link

melvin-bot bot commented Jun 20, 2024

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

@mallenexpensify mallenexpensify removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 20, 2024
@mallenexpensify
Copy link
Contributor

@c3024 likely add Help Wanted, any thoughts before I do?

@nkdengineer
Copy link
Contributor

nkdengineer commented Jun 20, 2024

Proposal

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

The total amount for the report in Shared is -0.00.

What is the root cause of that problem?

In

text={CurrencyUtils.convertToDisplayString((reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1) * (reportItem?.total ?? 0), reportItem?.currency)}
, we always multiply with -1 if it's an expense, even when the value is 0.

-1 * 0 will be -0, so it's displayed as -0 in front-end.

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

Only multiply if total is not 0

let total = reportItem?.total ?? 0;

if (total) {
    total *= (reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1);
}

After that total can be used in

text={CurrencyUtils.convertToDisplayString((reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1) * (reportItem?.total ?? 0), reportItem?.currency)}

text={CurrencyUtils.convertToDisplayString(total, reportItem?.currency)}

This can be made an utility to ensure consistency in this logic.

What alternative solutions did you explore? (Optional)

If value is -0, convert it to 0 inside convertToDisplayString or convertToFrontendAmountAsInteger

Example:

const amount = amountInCents === 0 ? 0 : amountInCents;

@nkdengineer
Copy link
Contributor

Proposal updated to add alternative solution

@Kalydosos
Copy link
Contributor

Kalydosos commented Jun 21, 2024

Proposal

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

The total amount for the report in Shared is -0.00.

What is the root cause of that problem?

In

text={CurrencyUtils.convertToDisplayString((reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1) * (reportItem?.total ?? 0), reportItem?.currency)}

indeed as nkdengineer stated you always multiply with -1 if it's an expense, even when the value is 0.

-1 * 0 will be -0, so it's displayed as -0 in front-end.

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

add 0 to the overall amount, the issue is hardcoded in javascript itself !!!

the line 42 will then be

text={CurrencyUtils.convertToDisplayString((reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? -1 : 1) * (reportItem?.total ?? 0) + 0, reportItem?.currency)}

What alternative solutions did you explore? (Optional)

Even better avoid such mutiplication by writing line 42 as

text={(reportItem?.type === CONST.REPORT.TYPE.EXPENSE ? "-" : "") + CurrencyUtils.convertToDisplayString((reportItem?.total ?? 0), reportItem?.currency)}

Copy link

melvin-bot bot commented Jun 21, 2024

📣 @iloveyourglasses! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:

  1. Make sure you've read and understood the contributing guidelines.
  2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
  3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
  4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
    Screen Shot 2022-11-16 at 4 42 54 PM
    Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>

@Kalydosos
Copy link
Contributor

Contributor details
Your Expensify account email: rnel2@hotmail.com
Upwork Profile Link: https://www.upwork.com/freelancers/~0182b95dfd9db2cbea

Copy link

melvin-bot bot commented Jun 21, 2024

✅ Contributor details stored successfully. Thank you for contributing to Expensify!

@c3024
Copy link
Contributor

c3024 commented Jun 21, 2024

@nkdengineer 's proposal here looks good to me. I found this use case at only one place so the primary solution looks fine to me.

🎀 👀 🎀 C+ Reviewed

Copy link

melvin-bot bot commented Jun 21, 2024

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

Copy link

melvin-bot bot commented Jun 21, 2024

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

Offer link
Upwork job

Copy link

melvin-bot bot commented Jun 21, 2024

📣 @nkdengineer 🎉 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 Weekly KSv2 and removed Daily KSv2 labels Jun 24, 2024
@nkdengineer
Copy link
Contributor

@c3024 this PR is ready for review

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jul 3, 2024
@melvin-bot melvin-bot bot changed the title [$250] Search - Total amount for the report in Shared is -0.00 when it has only scanning expenses [HOLD for payment 2024-07-10] [$250] Search - Total amount for the report in Shared is -0.00 when it has only scanning expenses Jul 3, 2024
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jul 3, 2024
Copy link

melvin-bot bot commented Jul 3, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Jul 3, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.3-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-07-10. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jul 3, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@c3024] The PR that introduced the bug has been identified. Link to the PR:
  • [@c3024] 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:
  • [@c3024] 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:
  • [@c3024] Determine if we should create a regression test for this bug.
  • [@c3024] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@mallenexpensify] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jul 10, 2024
@mallenexpensify
Copy link
Contributor

Contributor: @nkdengineer paid $250 via Upwork
Contributor+: @c3024 paid $250 via Upwork

@c3024 , please fill out the BZ checklist above. Thx

@c3024
Copy link
Contributor

c3024 commented Jul 11, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@c3024] The PR that introduced the bug has been identified. Link to the PR: Fix report total and alignment #42932
  • [@c3024] 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: nkdengineer@642baa4#r144114057
  • [@c3024] 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: No discussion was started because this is too specific a case and the bug could not have been identified earlier.
  • [@c3024] Determine if we should create a regression test for this bug. Yes
  • [@c3024] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.

Regression test proposal

  1. Submit two scan expenses in a workspace chat.
  2. While the scanning is ongoing, press on Search on Bottom Tab Bar.
  3. Press on Shared.
  4. Verify that the Total amount for this report (workspace chat of step 1) in Shared is displayed as 0.00.

Copy link

melvin-bot bot commented Jul 16, 2024

@arosiclair, @mallenexpensify, @c3024, @nkdengineer Huh... This is 4 days overdue. Who can take care of this?

@melvin-bot melvin-bot bot added the Overdue label Jul 16, 2024
Copy link

melvin-bot bot commented Jul 18, 2024

@arosiclair, @mallenexpensify, @c3024, @nkdengineer Still overdue 6 days?! Let's take care of this!

@arosiclair
Copy link
Contributor

@mallenexpensify is this done?

@mallenexpensify
Copy link
Contributor

is this done?

it is now!

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
Projects
No open projects
Archived in project
Development

No branches or pull requests

6 participants