-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix - Tax backwards compatibility - After disable Tax in OD display an it's not here page in ND #59565
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
Fix - Tax backwards compatibility - After disable Tax in OD display an it's not here page in ND #59565
Changes from all commits
2c09110
6525ee5
e6c2646
72f3d0d
28e51d6
6b70649
4523c69
276f183
77076c3
6134427
1b00abe
e699b64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* eslint-disable rulesdir/no-negated-variables */ | ||
import React, {useEffect, useState} from 'react'; | ||
import React, {useEffect} from 'react'; | ||
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import type {FullPageNotFoundViewProps} from '@components/BlockingViews/FullPageNotFoundView'; | ||
|
@@ -151,7 +151,6 @@ function AccessOrNotFoundWrapper({ | |
|
||
const isFeatureEnabled = featureName ? isPolicyFeatureEnabledUtil(policy, featureName) : true; | ||
|
||
const [isPolicyFeatureEnabled, setIsPolicyFeatureEnabled] = useState(isFeatureEnabled); | ||
const {isOffline} = useNetwork(); | ||
|
||
const isPageAccessible = accessVariants.reduce((acc, variant) => { | ||
|
@@ -160,15 +159,20 @@ function AccessOrNotFoundWrapper({ | |
}, true); | ||
|
||
const isPolicyNotAccessible = !isPolicyAccessible(policy); | ||
const shouldShowNotFoundPage = (!isMoneyRequest && !isFromGlobalCreate && isPolicyNotAccessible) || !isPageAccessible || !isPolicyFeatureEnabled || shouldBeBlocked; | ||
const shouldShowNotFoundPage = (!isMoneyRequest && !isFromGlobalCreate && isPolicyNotAccessible) || !isPageAccessible || shouldBeBlocked; | ||
// We only update the feature state if it isn't pending. | ||
// This is because the feature state changes several times during the creation of a workspace, while we are waiting for a response from the backend. | ||
// Without this, we can have unexpectedly have 'Not Found' be shown. | ||
// Without this, we can be unexpectedly navigated to the More Features page. | ||
useEffect(() => { | ||
if (pendingField && !isOffline && !isFeatureEnabled) { | ||
if (isFeatureEnabled || (pendingField && !isOffline && !isFeatureEnabled)) { | ||
return; | ||
} | ||
setIsPolicyFeatureEnabled(isFeatureEnabled); | ||
|
||
// When a workspace feature linked to the current page is disabled we will navigate to the More Features page. | ||
Navigation.isNavigationReady().then(() => Navigation.goBack(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes the scenario which caused the bug above on deep linking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we are overcomplicating it @eVoloshchak because what we are trying to achieve in this pr is navigating away from pages linked to a non-existing feature so the flash is totally expected and this is not also a common use case by the way a user deeplinking to a disabled feature. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It still doesn't look right, previously it worked without any flashing ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @eVoloshchak previously we used to show not found page now what we are implementing is navigating away to more features and the above behavior is acceptable. Moreover, showing not found page until the navigation is ready doesn't help at all because we can see the previous page for an extremely small amount of duration, I think we are overthinking here. @neil-marcellini WDYT about this. In my opinion, direct linking to a disabled feature is by itself very unlikely and if it happens what we are implementing in this pr is to navigate away to the more features page so the flashing is expected behavior. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I think that's acceptable. I don't even see it as much of a flash myself. Maybe there's a way it could be perfected, but let's not bother with it for such a rare edge case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
// We don't need to run the effect on policyID change as we only use it to get the route to navigate to. | ||
// eslint-disable-next-line react-compiler/react-compiler | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [pendingField, isOffline, isFeatureEnabled]); | ||
|
||
useEffect(() => { | ||
|
Uh oh!
There was an error while loading. Please reload this page.