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] [Track tax] Disabled tax rate can be selected #43613

Closed
6 tasks done
lanitochka17 opened this issue Jun 12, 2024 · 26 comments
Closed
6 tasks done
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

@lanitochka17
Copy link

lanitochka17 commented Jun 12, 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.82-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/4623265
Issue reported by: Applause - Internal Team

Action Performed:

Precondition:

  • Distance rates and Taxes are enabled
  • Track tax is enabled
  1. Go to staging.new.expensify.com
  2. Go to workspace settings > Taxes
  3. Disable a tax rate
  4. Go to Distance rates
  5. Click on any distance rate > Tax rate
  6. Select the disabled tax rate from Step 3
  7. Go to workspace chat and submit a distance expense
  8. Go to transaction thread

Expected Result:

In Step 6, app should prevent the disabled tax rate to be selected, which is the Old Dot behavior

Actual Result:

In Step 6, app allows the disabled tax rate to be selected
After submitting distance expense, it shows the "Tax no longer valid" violation

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

Add any screenshot/video evidence

Bug6511235_1718218613507.20240613_025108.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01b142f41c7ec7f0fd
  • Upwork Job ID: 1801464706663931905
  • Last Price Increase: 2024-06-14
  • Automatic offers:
    • hungvu193 | Reviewer | 102762156
    • Krishna2323 | Contributor | 102762157
Issue OwnerCurrent Issue Owner: @twisterdotcom / @stephanieelliott
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Jun 12, 2024
Copy link

melvin-bot bot commented Jun 12, 2024

Triggered auto assignment to @stephanieelliott (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
Copy link
Author

@stephanieelliott 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
Copy link
Author

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

@Krishna2323
Copy link
Contributor

Krishna2323 commented Jun 12, 2024

Proposal

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

Track tax - Disabled tax rate can be selected

What is the root cause of that problem?

Tax rates are not filtered based on the enabled state.

const taxRateItems: ListItemType[] = useMemo(() => {
const taxes = policy?.taxRates?.taxes;
const result = Object.entries(taxes ?? {}).map(([key, value]) => ({
value: key,
text: `${value.name} (${value.value})`,
isSelected: taxRateExternalID === key,
keyForList: key,
pendingAction: value.pendingAction,
isDisabled: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
}));
return result;
}, [policy, taxRateExternalID]);

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

Filter out disabled tax rates using isDisabled property.

    const taxRateItems: ListItemType[] = useMemo(
        () =>
            Object.entries(policy?.taxRates?.taxes ?? {})
                .filter(([, value]) => !value.isDisabled)
                .map(([key, value]) => ({
                    value: key,
                    text: `${value.name} (${value.value})`,
                    isSelected: taxRateExternalID === key,
                    keyForList: key,
                    pendingAction: value.pendingAction,
                    isDisabled: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE,
                })),
        [policy, taxRateExternalID],
    );

What alternative solutions did you explore? (Optional)

We can disable the option instead of filtering, in that case we just need to modify the isDisabled property.

isDisabled: value.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || value.isDisabled,

What alternative solutions did you explore? (Optional 2)

We can use TaxPicker component instead of SelectionList like we do in WorkspaceTaxesSettingsForeignCurrency .

{({insets}) => (
<>
<HeaderWithBackButton title={translate('workspace.taxes.foreignDefault')} />
<View style={[styles.mb4, styles.flex1]}>
<TaxPicker
selectedTaxRate={selectedTaxRate}
policyID={policyID}
insets={insets}
onSubmit={submit}
/>
</View>
</>
)}

@stephanieelliott stephanieelliott added the External Added to denote the issue can be worked on by a contributor label Jun 14, 2024
Copy link

melvin-bot bot commented Jun 14, 2024

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

@melvin-bot melvin-bot bot changed the title Track tax - Disabled tax rate can be selected [$250] Track tax - Disabled tax rate can be selected Jun 14, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jun 14, 2024
Copy link

melvin-bot bot commented Jun 14, 2024

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

@cretadn22
Copy link
Contributor

cretadn22 commented Jun 14, 2024

Proposal

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

Track tax - Disabled tax rate can be selected

What is the root cause of that problem?

In PolicyDistanceRateTaxRateEditPage.tsx, we refrain from utilizing TaxPicker, which includes the logic to exclude disabled rates

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

In PolicyDistanceRateTaxRateEditPage.tsx, it's advisable to reuse TaxPicker

<TaxPicker
  selectedTaxRate={selectedTaxRate}
  policyID={policyID}
  insets={insets}
  onSubmit={onTaxRateChange}
/>

We should also hide the selected tax rate if it's disabled (This will require updates in the WORKSPACE_DISTANCE_RATE_DETAILS page, which will be detailed in the pull request)

    const taxRateExternal = Object.values(TransactionUtils.transformedTaxRates(policy)).find((taxRate) => taxRate.code === taxRateExternalID);
    const selectedTaxRate = taxRateExternal?.isDisabled ? '' : TransactionUtils.getWorkspaceTaxesSettingsName(policy, taxRateExternalID);

We need to update onTaxRateChange function and eliminate any unused elements.

const onTaxRateChange = (newTaxRate: OptionsListUtils.TaxRatesOption) => {
        if (taxRateExternalID === newTaxRate.code) {
            Navigation.goBack();
            return;
        }
        DistanceRate.updateDistanceTaxRate(policyID, customUnit, [
            {
                ...rate,
                attributes: {
                    ...rate.attributes,
                    taxRateExternalID: newTaxRate.code,
                },
            },
        ]);
        Navigation.navigate(ROUTES.WORKSPACE_DISTANCE_RATE_DETAILS.getRoute(policyID, rateID));
    };

With this approach, after this PR is merged, we need to incorporate the onDismiss function and eliminate the existing logic to check duplicated tax in onTaxRateChange function

What alternative solutions did you explore? (Optional)

@hungvu193
Copy link
Contributor

hungvu193 commented Jun 14, 2024

Thanks for proposals everyone. I like the idea of reusing TaxPicker and I don't think we should hide disabled tax rate if it's selected. Because of that, I'm aligned with @Krishna2323 's alternative proposal here.
🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Jun 14, 2024

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

@amyevans amyevans changed the title [$250] Track tax - Disabled tax rate can be selected [$250] [Track tax] Disabled tax rate can be selected Jun 14, 2024
@amyevans
Copy link
Contributor

Since I'm headed out on leave after today, I won't be around to review the PR.

This looks like polish related to the Tax Track project, so I'm going to assign to you @MonilBhavsar 🙇

@amyevans amyevans assigned MonilBhavsar and unassigned amyevans Jun 14, 2024
@melvin-bot melvin-bot bot added the Overdue label Jun 17, 2024
@MonilBhavsar
Copy link
Contributor

Yes, let's fix it in TaxPicker component

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

melvin-bot bot commented Jun 17, 2024

📣 @hungvu193 🎉 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 17, 2024

📣 @Krishna2323 🎉 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 📖

@hungvu193
Copy link
Contributor

@Krishna2323 Do you have any ETA for the PR?

@Krishna2323
Copy link
Contributor

I will probably raise the PR today or tomorrow.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 Weekly KSv2 labels Jun 19, 2024
@Krishna2323
Copy link
Contributor

@hungvu193, PR ready for review.

@stephanieelliott
Copy link
Contributor

PR was merged to Main, should go to staging next deploy.

@stephanieelliott stephanieelliott added the NewFeature Something to build that is a new item. label Jul 3, 2024
Copy link

melvin-bot bot commented Jul 3, 2024

Triggered auto assignment to @twisterdotcom (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

@stephanieelliott stephanieelliott removed the NewFeature Something to build that is a new item. label Jul 3, 2024
@stephanieelliott
Copy link
Contributor

Applying the New Feature label to get another BZ member on this while I am OOO til July 10. To catch you up on where we are @twisterdotcom, we have a PR, it was merged to main last week and should be deployed to staging soon: #44046

Thanks for watching over this, I'll grab it back from you when I return!

@twisterdotcom
Copy link
Contributor

Easy peasy. I'm actually also out next week, so this will be pinged around a bit.

@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] [Track tax] Disabled tax rate can be selected [HOLD for payment 2024-07-10] [$250] [Track tax] Disabled tax rate can be selected 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:

  • [@hungvu193] The PR that introduced the bug has been identified. Link to the PR:
  • [@hungvu193] 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:
  • [@hungvu193] 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:
  • [@hungvu193] Determine if we should create a regression test for this bug.
  • [@hungvu193] 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.
  • [@twisterdotcom / @stephanieelliott] 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
@stephanieelliott
Copy link
Contributor

Hey @hungvu193 can you complete the NZ checklist please?

@stephanieelliott
Copy link
Contributor

Summarizing payment on this issue:

Upwork job is here: https://www.upwork.com/jobs/~01b142f41c7ec7f0fd

@hungvu193
Copy link
Contributor

  • The PR that introduced the bug has been identified. Link to the PR: Feature: Add the ability to configure tax rates on distance rates #42141
  • 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: https://github.com/Expensify/App/pull/42141/files#r1673377848
  • 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: N/A
  • Determine if we should create a regression test for this bug: No
    This is new feature and was recently added so I don't think we need regression test for this one.

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
Archived in project
Development

No branches or pull requests

8 participants