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.33k stars 2.76k forks source link

[Hold for payment 2024-09-09][$250] Track tax - Track tax feature is still available when Taxes feature is disabled offline #47421

Closed lanitochka17 closed 5 days ago

lanitochka17 commented 1 month 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.20-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: N/A Email or phone of affected tester (no customers): applausetester+kh050806@applause.expensifail.com Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to staging.new.expensify.com
  2. Go to workspace settings > More features
  3. Enable Distance rates and Taxes
  4. Go to Distance rates > Settings
  5. Enable Track tax
  6. Go offline
  7. Disable Taxes in More features
  8. Go to Distance rates > Settings
  9. Note that Track tax switch is still enabled but locked
  10. Click on any distance rate
  11. Note that Tax rate and Tax reclaimable on fields are still present when Taxes is disabled

Expected Result:

When disabling Taxes feature offline Step 9 - Track tax switch should be disabled and locked Step 11 - Tax rate and Tax reclaimable on fields should disappear

Actual Result:

When disabling Taxes feature offline Step 9 - Track tax switch is enabled and locked Step 11 - Tax rate and Tax reclaimable on fields are still present

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/user-attachments/assets/bb5ff826-f161-4a92-bd85-39379f58a489

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0125dfa57845b9c94e
  • Upwork Job ID: 1823746280169788016
  • Last Price Increase: 2024-08-21
  • Automatic offers:
    • etCoderDysto | Contributor | 103626049
Issue OwnerCurrent Issue Owner: @Ollyws
melvin-bot[bot] commented 1 month ago

Triggered auto assignment to @lschurr (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 1 month ago

@lschurr 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 1 month ago

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

etCoderDysto commented 1 month ago

Edited by proposal-police: This proposal was edited at 2024-08-14 13:28:19 UTC.

Proposal

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

Track tax feature is still available when Taxes feature is disabled offline

What is the root cause of that problem?

We are using isDistanceTrackTaxEnabled to determine if we should display tax features for

When user disable tax rate in offline mode, we are not optimistialy updating isDistanceTrackTaxEnabled (policy?.customUnits.customUnitID.customUnit?.attributes?.taxEnabled) to false as we do for isPolicyTrackTaxEnabled (policy?.tax?.trackingEnabled)

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

We should check also for isPolicyTrackTaxEnabled in the above places where we are using isDistanceTrackTaxEnabled, since isPolicyTrackTaxEnabled updated optimistically.

 <Switch
     isOn={isDistanceTrackTaxEnabled && isPolicyTrackTaxEnabled}

We will do the same for tax rates, and tax reclaimable as well

What alternative solutions did you explore? (Optional)

We can optimistially update isDistanceTrackTaxEnabled (policy?.customUnits.customUnitID.customUnit?.attributes?.taxEnabled) to false (enabled) in optimistic data, and to true (!enalbled) in failure data here

Some more details about creating optimistic customUnits data ```javascript const policy = getPolicy(policyID); const shouldAddDefaultTaxRatesData = (!policy?.taxRates || isEmptyObject(policy.taxRates)) && enabled; const customUnits = policy?.customUnits ?? {}; const customUnit = customUnits[Object.keys(customUnits)[0]]; const customUnitID = customUnit?.customUnitID ?? ''; ```
        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
            value: {
                customUnits: {
                    [customUnitID]: {
                        ...customUnit,
                        attributes: {
                            ...customUnit.attributes,
                            taxEnabled: customUnit.attributes.taxEnabled ? enabled : customUnit.attributes.taxEnabled,
                        },
                    },
                },
                tax: {
                    trackingEnabled: enabled,

We check for customUnit.attributes.taxEnabled to prevent assigning true to isDistanceTrackTaxEnabled and enabling Track Tax feature when the user enables tax rate on more features page but didn't enable Track Tax on DistanceRatesSettings page

melvin-bot[bot] commented 1 month ago

Job added to Upwork: https://www.upwork.com/jobs/~0125dfa57845b9c94e

melvin-bot[bot] commented 1 month ago

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

Ollyws commented 1 month ago

As taxes must be enabled on the policy in order to enable tax tracking on distance rates @etCoderDysto's proposal LGTM. πŸŽ€πŸ‘€πŸŽ€ C+ reviewed

melvin-bot[bot] commented 1 month ago

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

melvin-bot[bot] commented 3 weeks ago

@Ollyws, @lschurr, @mountiny Eep! 4 days overdue now. Issues have feelings too...

lschurr commented 3 weeks ago

@mountiny - looks like we just need a quick check from you. Can I assign this over to @etCoderDysto?

melvin-bot[bot] commented 3 weeks ago

πŸ“£ It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? πŸ’Έ

mountiny commented 3 weeks ago

Assigned, thanks for your patience

melvin-bot[bot] commented 3 weeks ago

πŸ“£ @etCoderDysto πŸŽ‰ 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 πŸ“–

etCoderDysto commented 2 weeks ago

@Ollyws PR is ready for review

Ollyws commented 6 days ago

Due for payment tomorrow @lschurr, Thanks!

lschurr commented 5 days ago

Payment summary:

Ollyws commented 5 days ago

Requested on ND.

garrettmknight commented 3 days ago

$250 approved for @Ollyws