You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[PAID] [$500] Web - Persistence of Tax Selection When Navigating to Other Pages and Returning #39492
Version Number: v1.4.59-3 Reproducible in staging?: y Reproducible in production?: y Issue reported by: Applause - Internal Team
Action Performed:
, Go to Settings > Profile > Workspace.
2, Open workspace and access "More Features" to enable taxes.
3, Select taxes from the list.
4, Navigate to another section.
5, Return to the previous section.
Expected Result:
Taxes should be deselected automatically upon navigating away and back.
Actual Result:
Selected taxes persist even after navigating to another section and returning, causing inconsistency between sections
Workaround:
n/a
Platforms:
Which of our officially supported platforms is this issue occurring on?
@strepanier03 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.
Please re-state the problem that we are trying to solve in this issue.
Web - Persistence of Tax Selection When Navigating to Other Pages and Returning
What is the root cause of that problem?
We don't have any logic to clean the selected options when route changes. Also it does happen on almost every policy feature page including the members page. The component doesn't get completely removed so the states are preserved.
What changes do you think we should make in order to solve the problem?
We should add a useEffect which will run on route change and clear all the selection. Or instead of using route name we can use useIsFocused and clear the selected option when screen is not focused.
Please re-state the problem that we are trying to solve in this issue.
Persistence of Tax Selection When Navigating to Other Pages and Returning
Selected Taxes still remain when we shift tabs.
What is the root cause of that problem?
OpenPolicyTaxesPage is not called everytime we navigate to page the taxes page. To compare with categories, we call OpenPolicyCategoriesPage everytime we open the categories page, this overwrites the locally selected values and we get data from the database.
Now OpenPolicyTaxesPage is not called because when we compare from where we take the route prop (it's onyx value) from PolicyRoute:
Or we can define a onyxentry for poicy, this way we can avoid any possible regression, so we can define a new type and add it in existing WorkspaceTaxesPageProps:
changed the title [-]Web - Persistence of Tax Selection When Navigating to Other Pages and Returning[/-][+][$500] Web - Persistence of Tax Selection When Navigating to Other Pages and Returning[/+]on Apr 3, 2024
In the future, since you can't update the labels or the title, feel free to ping me earlier for payment issues that fail automation. Failed automation = black hole for issues, sorry about that.
changed the title [-][$500] Web - Persistence of Tax Selection When Navigating to Other Pages and Returning[/-][+][PAID] [$500] Web - Persistence of Tax Selection When Navigating to Other Pages and Returning[/+]on May 10, 2024
The issue you are facing is because the default behaviour of stack navigation, when you select certain checkboxes on your “Taxes” screen it is stored in the state of the component and when you move to a different screen the stack navigation pushes the “Taxes” screen on to the navigation stack and the newer screen gets mounted and displayed, and what happens to the “Taxes” screen is that in never gets unmounted and is saved with it’s current state in the navigation stack. And when you move back to your “Taxes” screen it pops the “Taxes” screen back from the navigation stack and as it never got unmounted it displays again with it’s previous state and same checkboxes will still be selected. That’s just the default behaviour to the stack navigation.
Ideal solution of the issue:
The best solution in my opinion is that we should use “useIsFocused” hook from “react-navigation” what it does is that when the screen is in focus(being displayed) it returns a value of “true” which you can use in “useEffect” hook from “react” to check when the screen is popped from the navigation stack and comes into the focus and we can then update the state of the checkboxes to their initial state.
📣 @uzairusman1425! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
@uzairusman1425 Thanks for your interest! This issue is not open for proposals as it's already fixed. Please checkout issues with Help Wanted label where you can post a proposal. You should also check the contributing guide (linked in the comment above)
Please re-state the problem that we are trying to solve in this issue.
Selected taxes remain selected after navigating to other pages from the tax selection page.
What is the root cause of that problem?
The selected tax ids state variable is not reset on navigating away from the tax selection page.
What changes do you think we should make in order to solve the problem?
Solution 1 (local)
Use a reset state variable (useState) set to true when navigating away from the tax selection page. Call a reset function to reset the selected Tax IDs if reset is set to true in a useEffect hook with the reset state as a dependency (WorkspaceTaxesPage).
Solution 2 (global)
Add a callback function to the navigate method of Navigate (if a callback is required for other components/pages too) to reset the required state variables on navigate.
📣 @mariapeever! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Activity
melvin-bot commentedon Apr 3, 2024
Triggered auto assignment to @strepanier03 (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.kbecciv commentedon Apr 3, 2024
We think that this bug might be related to #wave-collect - Release 1
kbecciv commentedon Apr 3, 2024
@strepanier03 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.
Krishna2323 commentedon Apr 3, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Web - Persistence of Tax Selection When Navigating to Other Pages and Returning
What is the root cause of that problem?
We don't have any logic to clean the selected options when route changes. Also it does happen on almost every policy feature page including the members page. The component doesn't get completely removed so the states are preserved.
What changes do you think we should make in order to solve the problem?
We should add a useEffect which will run on route change and clear all the selection. Or instead of using route name we can use
useIsFocusedand clear the selected option when screen is not focused.If we use
isFocusedthen we can also remove the part where we clear selected options when navigating to option settings.App/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx
Lines 142 to 145 in ebc8de8
Result
Krishna2323 commentedon Apr 3, 2024
Proposal updated
allgandalf commentedon Apr 3, 2024
That PR didn't touch the Taxes folder @ZhenjaHorbach :)
ZhenjaHorbach commentedon Apr 3, 2024
I deleted comment )
allgandalf commentedon Apr 3, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Persistence of Tax Selection When Navigating to Other Pages and Returning
Selected Taxes still remain when we shift tabs.
What is the root cause of that problem?
OpenPolicyTaxesPageis not called everytime we navigate to page the taxes page. To compare with categories, we callOpenPolicyCategoriesPageeverytime we open the categories page, this overwrites the locally selected values and we get data from the database.Now
OpenPolicyTaxesPageis not called because when we compare from where we take therouteprop (it's onyx value) fromPolicyRoute:App/src/pages/workspace/withPolicy.tsx
Lines 100 to 102 in 255f841
But for categories we take the value of
routefrom it's onyx value:App/src/pages/workspace/categories/WorkspaceCategoriesPage.tsx
Line 51 in 4fcd8a1
What changes do you think we should make in order to solve the problem?
We need to update the type such that we should fetch value from
TaxRatesApp/src/types/onyx/Policy.ts
Line 61 in 255f841
Result Video:
simplescreenrecorder-2024-04-03_23.11.18.mp4
Alternative
Or we can define a
onyxentryforpoicy, this way we can avoid any possible regression, so we can define a new type and add it in existingWorkspaceTaxesPageProps:I would prefer my alternative solution over main one :), as it would avoid any further possible regression
[-]Web - Persistence of Tax Selection When Navigating to Other Pages and Returning[/-][+][$500] Web - Persistence of Tax Selection When Navigating to Other Pages and Returning[/+]melvin-bot commentedon Apr 3, 2024
Job added to Upwork: https://www.upwork.com/jobs/~0167f336d9308b4e85
45 remaining items
Krishna2323 commentedon May 10, 2024
@strepanier03, offer accepted 🙃
s77rt commentedon May 10, 2024
Accepted from side too
strepanier03 commentedon May 10, 2024
Great, thank you both, finishing up now.
In the future, since you can't update the labels or the title, feel free to ping me earlier for payment issues that fail automation. Failed automation = black hole for issues, sorry about that.
strepanier03 commentedon May 10, 2024
Contracts paid and closed. Thanks again, and apologies for the long delay.
[-][$500] Web - Persistence of Tax Selection When Navigating to Other Pages and Returning[/-][+][PAID] [$500] Web - Persistence of Tax Selection When Navigating to Other Pages and Returning[/+]uzairusman1425 commentedon May 10, 2024
Cause of the issue:
The issue you are facing is because the default behaviour of stack navigation, when you select certain checkboxes on your “Taxes” screen it is stored in the state of the component and when you move to a different screen the stack navigation pushes the “Taxes” screen on to the navigation stack and the newer screen gets mounted and displayed, and what happens to the “Taxes” screen is that in never gets unmounted and is saved with it’s current state in the navigation stack. And when you move back to your “Taxes” screen it pops the “Taxes” screen back from the navigation stack and as it never got unmounted it displays again with it’s previous state and same checkboxes will still be selected. That’s just the default behaviour to the stack navigation.
Ideal solution of the issue:
The best solution in my opinion is that we should use “useIsFocused” hook from “react-navigation” what it does is that when the screen is in focus(being displayed) it returns a value of “true” which you can use in “useEffect” hook from “react” to check when the screen is popped from the navigation stack and comes into the focus and we can then update the state of the checkboxes to their initial state.
melvin-bot commentedon May 10, 2024
📣 @uzairusman1425! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Format:
s77rt commentedon May 11, 2024
@uzairusman1425 Thanks for your interest! This issue is not open for proposals as it's already fixed. Please checkout issues with Help Wanted label where you can post a proposal. You should also check the contributing guide (linked in the comment above)
mariapeever commentedon May 11, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Selected taxes remain selected after navigating to other pages from the tax selection page.
What is the root cause of that problem?
The selected tax ids state variable is not reset on navigating away from the tax selection page.
What changes do you think we should make in order to solve the problem?
Solution 1 (local)
Use a reset state variable (useState) set to true when navigating away from the tax selection page. Call a reset function to reset the selected Tax IDs if reset is set to true in a useEffect hook with the reset state as a dependency (WorkspaceTaxesPage).
Solution 2 (global)
Add a callback function to the navigate method of Navigate (if a callback is required for other components/pages too) to reset the required state variables on navigate.
melvin-bot commentedon May 11, 2024
📣 @mariapeever! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Format:
mariapeever commentedon May 11, 2024
Contributor details
Your Expensify account email: hello@mariapeever.com
Upwork Profile Link: https://www.upwork.com/freelancers/mariapeever
melvin-bot commentedon May 11, 2024
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
s77rt commentedon May 12, 2024
@mariapeever Please check my comment above