Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.56k stars 2.9k forks source link

[HOLD for payment 2024-07-24] [$250] Split tax - Tax amount is negative when manually entering tax amount when splitting expense #44632

Closed lanitochka17 closed 3 months ago

lanitochka17 commented 4 months ago

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: 9.0-3.2 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/4678911 Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

Expected Result:

The tax amount will not be negative

Actual Result:

The tax amount is negative when manually entering tax amount when splitting expense

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/78819774/4551dcf0-6163-4320-93e0-874312a2ba63

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01f472383a767ded73
  • Upwork Job ID: 1808173052119824825
  • Last Price Increase: 2024-07-02
Issue OwnerCurrent Issue Owner: @CortneyOfstad
melvin-bot[bot] commented 4 months ago

Triggered auto assignment to @CortneyOfstad (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.

lanitochka17 commented 4 months ago

@CortneyOfstad FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

lanitochka17 commented 4 months ago

We think that this bug might be related to #wave-collect - Release 1

etCoderDysto commented 4 months ago

Proposal

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

What is the root cause of that problem?

BE returns negative tax amount when editing tax amount manually. And we convert the negative tax amount to formatted tax amount here in MoneyRequestConfimationListFooter without first converting the tax amount into positive value as we do in MoneyRequestView. https://github.com/Expensify/App/blob/937c4186409725b57fdaae6ae8e1d8c85a9d52a0/src/components/MoneyRequestConfirmationListFooter.tsx#L254

And display the formatted value here https://github.com/Expensify/App/blob/937c4186409725b57fdaae6ae8e1d8c85a9d52a0/src/components/MoneyRequestConfirmationListFooter.tsx#L484-L487

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

As we do in MoneyRequestView, we should first convert the taxAmount to positive following the same method used in Money RequestVeiw

const taxAmount = TransactionUtils.getTaxAmount(transaction, false);

getTaxAmount() returns the absolute value of transaction.taxAmount

Then we format it

const formattedTaxAmount = CurrencyUtils.convertToDisplayString(taxAmount, iouCurrencyCode);

here

https://github.com/Expensify/App/blob/937c4186409725b57fdaae6ae8e1d8c85a9d52a0/src/components/MoneyRequestConfirmationListFooter.tsx#L254C11-L254C29

Note: Instead of passing false as isExpenseReport param to 'getTaxAmount', we can calculate isExpenseReport using TransactionUtils.isExpenseReport(report)).

What alternative solutions did you explore? (Optional)

nkdengineer commented 4 months ago

Proposal

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

The tax amount is negative when manually entering tax amount when splitting expense

What is the root cause of that problem?

If we create a split bill with entering the tax amount manually, BE returns the tax amount as negative amount for expense report.

And in here, we doesn't convert the tax mount to positive value before getting the formatted string. https://github.com/Expensify/App/blob/5cebd3ebb70e95a66ecdd60b3057027b619da39a/src/components/MoneyRequestConfirmationListFooter.tsx#L254

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

If we create a split bill with entering the tax amount manually, BE returns the tax amount as negative amount for expense report.

With this case BE returns the tax amount as negative amount for expense report. But if we don't enter the tax amount manually, BE returns it as positive amount. So here we should use getTaxAmountAbsValue to make sure that the displayed tax amount is always positive value

const formattedTaxAmount = CurrencyUtils.convertToDisplayString(ModifiedExpenseMessage.getTaxAmountAbsValue(transaction?.taxAmount ?? 0), iouCurrencyCode);

https://github.com/Expensify/App/blob/5cebd3ebb70e95a66ecdd60b3057027b619da39a/src/components/MoneyRequestConfirmationListFooter.tsx#L254

What alternative solutions did you explore? (Optional)

We can fix from BE side to always return the tax amount of split bill transaction in expense report as negative amount And then here, we can use getTaxAmount function that had already covered the negative amount case for expense chat.

const formattedTaxAmount = CurrencyUtils.convertToDisplayString(TransactionUtils.getTaxAmount(transaction, isPolicyExpenseChat), iouCurrencyCode);

https://github.com/Expensify/App/blob/5cebd3ebb70e95a66ecdd60b3057027b619da39a/src/components/MoneyRequestConfirmationListFooter.tsx#L254

melvin-bot[bot] commented 4 months ago

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

CortneyOfstad commented 4 months ago

I was able to recreate so going to get eyes on this!

melvin-bot[bot] commented 4 months ago

Job added to Upwork: https://www.upwork.com/jobs/~01f472383a767ded73

melvin-bot[bot] commented 4 months ago

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

CortneyOfstad commented 4 months ago

@aimane-chnaif there are two proposals here and here for review when you have a chance β€” thank you!

aimane-chnaif commented 4 months ago

Thanks for the proposals.

We can fix from BE side to always return the tax amount of split bill transaction in expense report as negative amount

@nkdengineer have you found any case where @etCoderDysto's solution is not working?

- const formattedTaxAmount = CurrencyUtils.convertToDisplayString(transaction?.taxAmount, iouCurrencyCode);
+ const formattedTaxAmount = CurrencyUtils.convertToDisplayString(TransactionUtils.getTaxAmount(transaction, false), iouCurrencyCode);
nkdengineer commented 4 months ago

@aimane-chnaif I can't find.

aimane-chnaif commented 4 months ago

@etCoderDysto's proposal looks good. They're the first to provide root cause and working solution. πŸŽ€πŸ‘€πŸŽ€ C+ reviewed

melvin-bot[bot] commented 4 months ago

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

etCoderDysto commented 4 months ago

Hi @hayata-suenaga, should I go on with creating the PR?

hayata-suenaga commented 4 months ago

sorry I have been sick for a while. yes! let's go with your proposal, @etCoderDysto! πŸ˜„

melvin-bot[bot] commented 4 months ago

πŸ“£ @etCoderDysto You have been assigned to this job! Please apply to the Upwork job and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review πŸ§‘β€πŸ’» Once you apply to this job, your Upwork ID will be stored and you will be automatically hired for future jobs! Keep in mind: Code of Conduct | Contributing πŸ“–

etCoderDysto commented 4 months ago

sorry I have been sick for a while. yes! let's go with your proposal, @etCoderDysto! πŸ˜„

Np 😁. I hope you are feeling better now.

etCoderDysto commented 4 months ago

PR will be ready for review in few hours.

etCoderDysto commented 4 months ago

@aimane-chnaif PR is ready for review.

melvin-bot[bot] commented 4 months ago

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

melvin-bot[bot] commented 4 months ago

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

If no regressions arise, payment will be issued on 2024-07-24. :confetti_ball:

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

melvin-bot[bot] commented 4 months ago

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:

melvin-bot[bot] commented 3 months ago

Payment Summary

Upwork Job

BugZero Checklist (@CortneyOfstad)

CortneyOfstad commented 3 months ago

@aimane-chnaif β€” please complete the check ASAP so there is no further delay in payment. Thanks!

@etCoderDysto β€” I sent you an offer in Upwork, please let me know once you accept and I will get that paid ASAP. Thanks!

etCoderDysto commented 3 months ago

@CortneyOfstad I have accepted the offer. Thank you!

aimane-chnaif commented 3 months ago

Offending PR with comment: https://github.com/Expensify/App/pull/32550#issuecomment-2248669786

We already have regression test as stated in OP

CortneyOfstad commented 3 months ago

Payment Summary

@etCoderDysto β€” paid $250 via Upwork @aimane-chnaif β€” to be paid $250 via NewDot

Thanks all!

aimane-chnaif commented 1 month ago

@CortneyOfstad I am still using upwork. Can you please reopen and sort payment? Thanks