Skip to content

[HOLD for payment 2025-01-13] Distance - Inconsistency in Tax field when both distance rate and category have different tax #54513

Closed

Description

@IuliiaHerets

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.78-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both
If this was caught during regression testing, add the test name, ID and link from TestRail: Exp
Email or phone of affected tester (no customers): applausetester+kh03120001@applause.expensifail.com
Issue reported by: Applause Internal Team
Device used: Windows 11
App Component: Money Requests

Action Performed:

Precondition:

  • Rules, Distance rates, and Taxes are enabled.
  • There are two non-zero tax rates - Tax rate A and Tax rate B.
  • Track tax is enabled.
  • Distance rate is assigned with tax rate A.
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Categories.
  3. Click Advertising category.
    4 Click Default tax rate.
  4. Select Tax rate B.
  5. Go to workspace chat.
  6. Click + > Submit expense > Distance.
  7. Enter waypoints > Next.
  8. On confirmation page, note that the distance tax rate is Tax rate A (follows distance rate track tax).
  9. Click Category.
  10. Select Advertising category from Step 3.
  11. Note that the distance tax rate is Tax rate B (follows the category).
  12. Submit the expense.
  13. Go to transaction thread.
  14. Note that the distance tax rate is back to Tax rate A.

Expected Result:

When submitting distance expense with distance rate that has tax rate and category with its own tax rate, the tax field should follow the tax rate from distance rate.

Actual Result:

In Step 12, after selecting category with own tax rate, the Tax field changes to the rate from the selected category, while the tax amount remains unchanged.
In Step 15, after submitting the distance expense, the Tax field changes back to the tax rate that follows distance rate.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6701707_1735032557064.bandicam_2024-12-24_17-18-24-974.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @Christinadobrzyn

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Dec 24, 2024
  2. melvin-bot commented on Dec 24, 2024

    @melvin-bot

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

  3. melvin-bot commented on Dec 24, 2024

    @melvin-bot

    Triggered auto assignment to @youssef-lr (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

  4. melvin-bot commented on Dec 24, 2024

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  5. github-actions commented on Dec 24, 2024

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. Christinadobrzyn commented on Dec 24, 2024

    @Christinadobrzyn
    Contributor

    hum... maybe related to - #53789? Asking

  7. Christinadobrzyn commented on Dec 24, 2024

    @Christinadobrzyn
    Contributor

    Neil and the contributor of #53789 don't think it's related... I'll keep digging to see if I can find the culprit..

  8. nkdengineer commented on Dec 25, 2024

    @nkdengineer
    Contributor

    Edited by proposal-police: This proposal was edited at 2024-12-25 08:13:40 UTC.

    Proposal

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

    In Step 12, after selecting category with own tax rate, the Tax field changes to the rate from the selected category, while the tax amount remains unchanged.
    In Step 15, after submitting the distance expense, the Tax field changes back to the tax rate that follows distance rate.

    What is the root cause of that problem?

    Here, we always update tax code and tax amount when we change the category without checking the correct tax is the distance rate tax or not.

    const {categoryTaxCode, categoryTaxAmount} = TransactionUtils.getCategoryTaxCodeAndAmount(category, transaction, PolicyUtils.getPolicy(policyID));

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

    Since the distance rate tax should be prioritized, we should update getCategoryTaxCodeAndAmount to return categoryTaxCode and categoryTaxAmount as undefined if the current tax code is distance rate tax.

    const taxRules = policy?.rules?.expenseRules?.filter((rule) => rule.tax);
    const currentTaxCode = getTaxCode(transaction);
    const customUnitRateID = transaction?.comment?.customUnit?.customUnitRateID ?? '-1';
    const policyCustomUnitRate = getDistanceRateCustomUnitRate(policy, customUnitRateID);
    const taxRateExternalID = policyCustomUnitRate?.attributes?.taxRateExternalID ?? '-1';
    if (!taxRules || taxRules?.length === 0 || taxRateExternalID === currentTaxCode) {
        return {categoryTaxCode: undefined, categoryTaxAmount: undefined};
    }
    

    const {categoryTaxCode, categoryTaxAmount} = TransactionUtils.getCategoryTaxCodeAndAmount(category, transaction, PolicyUtils.getPolicy(policyID));

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    Add a test case for getCategoryTaxCodeAndAmount and confirm that it returns categoryTaxCode and categoryTaxAmount as undefined if the current tax code is distance rate tax.

    What alternative solutions did you explore? (Optional)

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  9. 17 remaining items

  10. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Jan 6, 2025
  11. changed the title [-]Distance - Inconsistency in Tax field when both distance rate and category have different tax[/-] [+][HOLD for payment 2025-01-13] Distance - Inconsistency in Tax field when both distance rate and category have different tax[/+] on Jan 6, 2025
  12. melvin-bot commented on Jan 6, 2025

    @melvin-bot

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

  13. melvin-bot commented on Jan 6, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.80-6 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 2025-01-13. 🎊

  14. melvin-bot commented on Jan 6, 2025

    @melvin-bot

    @youssef-lr / @MonilBhavsar @Christinadobrzyn @youssef-lr / @MonilBhavsar The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  15. melvin-bot commented on Jan 13, 2025

    @melvin-bot

    Skipping the payment summary for this issue since all the assignees are employees or vendors. If this is incorrect, please manually add the payment summary SO.

  16. Christinadobrzyn commented on Jan 13, 2025

    @Christinadobrzyn
    Contributor

    Looks like this can be closed! No payment needed.

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions