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

[Onyx] Move policyTaxRates_ key back into the policy_ key #36171

Closed
flodnv opened this issue Feb 8, 2024 · 19 comments
Closed

[Onyx] Move policyTaxRates_ key back into the policy_ key #36171

flodnv opened this issue Feb 8, 2024 · 19 comments
Assignees
Labels
Engineering Internal Requires API changes or must be handled by Expensify staff Monthly KSv2 Reviewing Has a PR in review Task

Comments

@flodnv
Copy link
Contributor

flodnv commented Feb 8, 2024

Problem & Solution

Sister issue: #36170

Discussed internally, summarised here and concluded there

  • We added the onyx keys policyTaxRates_ and policyReportFields_ for no good reason. There's no size to optimize for in these collections.
  • This makes my life harder in trying to fix an architectural problem of sending policy updates in https://github.com/Expensify/Auth/pull/9773 (see https://expensify.slack.com/archives/C03TQ48KC/p1706285244529629 & [Backwards Compatibility] [HIGH] Push all policy updates to all policy members forever #34834)
  • This makes code more complex than it needs to be (lots of existing data massaging for really no gain)
  • As such, we should kill and fix this unnecessarily complex code that was recently introduced. This means, at a minimum (I might be missing things):
    • Moving this data back into the policy_ key
    • Removing any data massaging from the backend
    • Have the frontend accept the same data as what's in the database
    • Where we should not display disabled fields, then let's use the disabled property to hide them. We will need to display them to admins soon enough
  • No need to worry about sending updates to policy members when the policy changes, that will be done as part of https://github.com/Expensify/Auth/pull/9773, which includes doing this for all current and future policy attributes

cc @iwiznia @puneetlath @tgolen @marcaaron @francoisl @dangrous @johnmlee101 @stitesExpensify @thienlnam @nkuoch @AndrewGable @luacmartins

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~019f2faa357c786564
  • Upwork Job ID: 1755673931208187904
  • Last Price Increase: 2024-02-08
@flodnv flodnv added Engineering Daily KSv2 Internal Requires API changes or must be handled by Expensify staff Task labels Feb 8, 2024
Copy link

melvin-bot bot commented Feb 8, 2024

Job added to Upwork: https://www.upwork.com/jobs/~019f2faa357c786564

Copy link

melvin-bot bot commented Feb 8, 2024

Triggered auto assignment to Contributor Plus for review of internal employee PR - @getusha (Internal)

@flodnv
Copy link
Contributor Author

flodnv commented Feb 8, 2024

I just realized we also need to fix the location of isTaxTrackingEnabled like we did in https://github.com/Expensify/Web-Expensify/pull/40728 for harvesting...

cc @mountiny

@mountiny
Copy link
Contributor

mountiny commented Feb 8, 2024

@flodnv Made an issue for this here #36176 and will address it

Also noted on this PR https://github.com/Expensify/Auth/pull/9677/files

@iwiznia
Copy link
Contributor

iwiznia commented Feb 8, 2024

Removing any data massaging from the backend

The data in onyx is an object keyed by fieldID but in the DB is an array, so I think we can't do this

@melvin-bot melvin-bot bot added the Overdue label Feb 12, 2024
Copy link

melvin-bot bot commented Feb 12, 2024

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

@MonilBhavsar
Copy link
Contributor

MonilBhavsar commented Feb 13, 2024

The plan is to

  1. Have Web-E send tax details in policy_ onyx along with policyTaxRates_ key
  2. Update App to use policy_ key for tax rates
  3. After some time, completely deprecate policyTaxRates_ from server

@melvin-bot melvin-bot bot removed the Overdue label Feb 13, 2024
@teneeto
Copy link
Contributor

teneeto commented Feb 13, 2024

Hi, I'm Eto from Callstack - expert contributor group - and I would like to take care of this issue.

@tgolen
Copy link
Contributor

tgolen commented Feb 13, 2024 via email

@flodnv
Copy link
Contributor Author

flodnv commented Feb 13, 2024

Also, is the plan to store tax details in policy_ in the same place they are in the DB, aka in the expenseUDFs key?

@marcaaron
Copy link
Contributor

After some time, completely deprecate policyTaxRates_ from server

Oh also, anytime we force users to upgrade to a new app version would be a good opportunity to remove this code. Then we don't have to consider how much time is "enough" before removing things. Not sure if I'd force an upgrade for this though and we haven't used this yet.

@MonilBhavsar
Copy link
Contributor

From this SO https://stackoverflowteams.com/c/expensify/questions/14164 I think we don't require Onyx migration
This case is very similar to

The name of a key has changed (because it should get the new data from the server stored on the new key when they open the app)

Where we're moving data from one Onyx key to another and currently client is only reading that data

@MonilBhavsar
Copy link
Contributor

Also, is the plan to store tax details in policy_ in the same place they are in the DB, aka in the expenseUDFs key?

No, under the taxRates key and in the form of object. Object only contains required data and in the format that can simply be rendered

@MonilBhavsar
Copy link
Contributor

Oh also, anytime we force users to upgrade to a new app version would be a good opportunity to remove this code. Then we don't have to consider how much time is "enough" before removing things. Not sure if I'd force an upgrade for this though and we haven't used this yet.

Yes correct! We can note an app version where the App PR is deployed to production and once MINIMUM_APP_VERSION is updated to greater than the version we can safely remove the code. Will bump priority to Monthly to cleanup the code.

@teneeto
Copy link
Contributor

teneeto commented Feb 19, 2024

@MonilBhavsar I raised a draft_PR where taxRates are been applied from policy_ rather than policyTaxRates_.

This is done for the main branch for now. I'm currently updating on edit fields PR as well.

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Feb 19, 2024
@MonilBhavsar MonilBhavsar added the Reviewing Has a PR in review label Feb 21, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Overdue Daily KSv2 labels Feb 21, 2024
@MonilBhavsar
Copy link
Contributor

MonilBhavsar commented Feb 29, 2024

App PR is merged and deployed to production in version 1.4.44-13.
Once Minimum App version is set to 1.4.44-13, we'll deprecate policyTaxRates_ from Web-E completely

@MonilBhavsar MonilBhavsar added Monthly KSv2 and removed Reviewing Has a PR in review Weekly KSv2 labels Feb 29, 2024
@luacmartins
Copy link
Contributor

cc @kosmydel @filip-solecki since you're working on the Simplified Collect: Taxes doc too

@MonilBhavsar
Copy link
Contributor

As per this comment https://github.com/Expensify/Auth/pull/9773#discussion_r1516014889
Need to update Onyx keys in auth once that PR is shipped

@MonilBhavsar
Copy link
Contributor

All PR's are deployed and policyTaxRates_ collection is removed. So closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Engineering Internal Requires API changes or must be handled by Expensify staff Monthly KSv2 Reviewing Has a PR in review Task
Projects
None yet
Development

No branches or pull requests

9 participants