Skip to content

Commit

Permalink
Merge pull request #41288 from Expensify/marco-hideAnonymousEmail
Browse files Browse the repository at this point in the history
[CP Staging] Hide anonymous email in user details tooltip and profile page
  • Loading branch information
thienlnam authored May 1, 2024
2 parents c417a45 + 6c9ad8f commit 142d7b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
import Str from 'expensify-common/lib/str';
import React, {useCallback} from 'react';
import {View} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import Avatar from '@components/Avatar';
import {usePersonalDetails} from '@components/OnyxProvider';
import Text from '@components/Text';
import Tooltip from '@components/Tooltip';
import type UserDetailsTooltipProps from '@components/UserDetailsTooltip/types';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import {isAnonymousUser} from '@libs/actions/Session';
import * as LocalePhoneNumber from '@libs/LocalePhoneNumber';
import * as ReportUtils from '@libs/ReportUtils';
import * as UserUtils from '@libs/UserUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';

function BaseUserDetailsTooltip({accountID, fallbackUserDetails, icon, delegateAccountID, shiftHorizontal, children}: UserDetailsTooltipProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const personalDetails = usePersonalDetails();
const [session] = useOnyx(ONYXKEYS.SESSION);
const isCurrentUserAnonymous = session?.accountID === accountID && isAnonymousUser(session);

const userDetails = personalDetails?.[accountID] ?? fallbackUserDetails ?? {};
let userDisplayName = ReportUtils.getUserDetailTooltipText(accountID, userDetails.displayName ? userDetails.displayName.trim() : '');
let userLogin = userDetails.login?.trim() && userDetails.login !== userDetails.displayName ? Str.removeSMSDomain(userDetails.login) : '';
let userLogin = !isCurrentUserAnonymous && userDetails.login?.trim() && userDetails.login !== userDetails.displayName ? Str.removeSMSDomain(userDetails.login) : '';

let userAvatar = userDetails.avatar;
let userAccountID = accountID;
Expand Down
3 changes: 2 additions & 1 deletion src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ function ProfilePage({route}: ProfilePageProps) {
</View>
)}

{login ? (
{/* Don't display email if current user is anonymous */}
{!(isCurrentUser && SessionActions.isAnonymousUser()) && login ? (
<View style={[styles.mb6, styles.detailsPageSectionContainer, styles.w100]}>
<Text
style={[styles.textLabelSupporting, styles.mb1]}
Expand Down

0 comments on commit 142d7b6

Please sign in to comment.