Skip to content

Commit

Permalink
Merge pull request Expensify#56352 from FitseTLT/fix-back-navigation-…
Browse files Browse the repository at this point in the history
…on-expensify-delegate-no-access

fix - Expensify Card - Back button on Not so fast page closes RHP instead of returning to profile page
  • Loading branch information
mjasikowski authored Feb 12, 2025
2 parents 6000b2a + 55e2f56 commit 5ddef34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/components/DelegateNoAccessWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type DelegateNoAccessWrapperProps = {
accessDeniedVariants?: AccessDeniedVariants[];
shouldForceFullScreen?: boolean;
children?: (() => React.ReactNode) | React.ReactNode;
onBackButtonPress?: () => void;
};

function isDelegate(account: OnyxEntry<Account>) {
Expand All @@ -35,7 +36,7 @@ function isSubmitter(account: OnyxEntry<Account>) {
return isDelegateOnlySubmitter;
}

function DelegateNoAccessWrapper({accessDeniedVariants = [], shouldForceFullScreen, ...props}: DelegateNoAccessWrapperProps) {
function DelegateNoAccessWrapper({accessDeniedVariants = [], shouldForceFullScreen, onBackButtonPress, ...props}: DelegateNoAccessWrapperProps) {
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
const isPageAccessDenied = accessDeniedVariants.reduce((acc, variant) => {
const accessDeniedFunction = DENIED_ACCESS_VARIANTS[variant];
Expand All @@ -49,6 +50,10 @@ function DelegateNoAccessWrapper({accessDeniedVariants = [], shouldForceFullScre
shouldShow
shouldForceFullScreen={shouldForceFullScreen}
onBackButtonPress={() => {
if (onBackButtonPress) {
onBackButtonPress();
return;
}
if (shouldUseNarrowLayout) {
Navigation.dismissModal();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {useOnyx} from 'react-native-onyx';
import DelegateNoAccessWrapper from '@components/DelegateNoAccessWrapper';
import ScreenWrapper from '@components/ScreenWrapper';
import {startIssueNewCardFlow} from '@libs/actions/Card';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types';
import type {SettingsNavigatorParamList} from '@navigation/types';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
Expand Down Expand Up @@ -63,7 +64,10 @@ function IssueNewCardPage({policy, route}: IssueNewCardPageProps) {
includeSafeAreaPaddingBottom={false}
shouldEnablePickerAvoiding={false}
>
<DelegateNoAccessWrapper accessDeniedVariants={[CONST.DELEGATE.DENIED_ACCESS_VARIANTS.DELEGATE]} />
<DelegateNoAccessWrapper
accessDeniedVariants={[CONST.DELEGATE.DENIED_ACCESS_VARIANTS.DELEGATE]}
onBackButtonPress={() => Navigation.goBack(backTo)}
/>
</ScreenWrapper>
);
}
Expand Down

0 comments on commit 5ddef34

Please sign in to comment.