Skip to content

Commit

Permalink
Merge pull request #42769 from software-mansion-labs/kicu/42750-profi…
Browse files Browse the repository at this point in the history
…le-fix

Fix normal Profile Page displayed for invalid accountID
  • Loading branch information
mountiny authored Jun 3, 2024
2 parents 79406ff + 466639f commit e174f18
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ 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 isValidAccountID = ValidationUtils.isValidAccountRoute(accountID);
const details: PersonalDetails | EmptyObject = personalDetails?.[accountID] ?? (isValidAccountID ? {} : {accountID: 0});

const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(details, undefined, undefined, isCurrentUser);
const fallbackIcon = details?.fallbackIcon ?? '';
Expand All @@ -116,6 +117,7 @@ function ProfilePage({route}: ProfilePageProps) {

const hasAvatar = Boolean(details.avatar);
const isLoading = Boolean(personalDetailsMetadata?.[accountID]?.isLoading) || isEmptyObject(details);
const shouldShowBlockingView = (!isValidAccountID && !isLoading) || CONST.RESTRICTED_ACCOUNT_IDS.includes(accountID);

const statusEmojiCode = details?.status?.emojiCode ?? '';
const statusText = details?.status?.text ?? '';
Expand All @@ -139,7 +141,7 @@ function ProfilePage({route}: ProfilePageProps) {

return (
<ScreenWrapper testID={ProfilePage.displayName}>
<FullPageNotFoundView shouldShow={CONST.RESTRICTED_ACCOUNT_IDS.includes(accountID)}>
<FullPageNotFoundView shouldShow={shouldShowBlockingView}>
<HeaderWithBackButton
title={translate('common.profile')}
onBackButtonPress={() => Navigation.goBack(navigateBackTo)}
Expand Down

0 comments on commit e174f18

Please sign in to comment.