Skip to content

Commit

Permalink
#42841 - Unknown user profile loads infinitely
Browse files Browse the repository at this point in the history
  • Loading branch information
PrinceMakavana committed May 31, 2024
1 parent 5699ae3 commit cd39e97
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {StackScreenProps} from '@react-navigation/stack';
import Str from 'expensify-common/lib/str';
import React, {useEffect, useMemo} from 'react';
import React, {useEffect, useMemo, useState} from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
Expand Down Expand Up @@ -92,7 +92,7 @@ function ProfilePage({route}: ProfilePageProps) {
const {translate, formatPhoneNumber} = useLocalize();
const accountID = Number(route.params?.accountID ?? 0);
const isCurrentUser = session?.accountID === accountID;
const details: PersonalDetails | EmptyObject = personalDetails?.[accountID] ?? (ValidationUtils.isValidAccountRoute(accountID) ? {} : {accountID: 0});
const [details , setDetails] = useState<PersonalDetails | EmptyObject>(personalDetails?.[accountID] ?? (ValidationUtils.isValidAccountRoute(accountID) ? {} : {accountID: 0}));

const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(details, undefined, undefined, isCurrentUser);
const fallbackIcon = details?.fallbackIcon ?? '';
Expand Down Expand Up @@ -137,6 +137,11 @@ function ProfilePage({route}: ProfilePageProps) {
}
}, [accountID]);

useEffect(() => {
if(details?.accountID == undefined){
Navigation.goBack(navigateBackTo);
}
}, [])
return (
<ScreenWrapper testID={ProfilePage.displayName}>
<FullPageNotFoundView shouldShow={CONST.RESTRICTED_ACCOUNT_IDS.includes(accountID)}>
Expand Down

0 comments on commit cd39e97

Please sign in to comment.