Skip to content
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 normal Profile Page displayed for invalid accountID #42769

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming styles

Suggested change
const isValidAccountId = ValidationUtils.isValidAccountRoute(accountID);
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const shouldShowBlockingView = !isValidAccountId && !isLoading;
const shouldShowBlockingView = (!isValidAccountId && !isLoading) || CONST.RESTRICTED_ACCOUNT_IDS.includes(accountID);

NAB

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1


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 || CONST.RESTRICTED_ACCOUNT_IDS.includes(accountID)}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • the other suggestion
Suggested change
<FullPageNotFoundView shouldShow={shouldShowBlockingView || CONST.RESTRICTED_ACCOUNT_IDS.includes(accountID)}>
<FullPageNotFoundView shouldShow={shouldShowBlockingView}>

<HeaderWithBackButton
title={translate('common.profile')}
onBackButtonPress={() => Navigation.goBack(navigateBackTo)}
Expand Down
Loading