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: System throws a technical error message on clicking 'Message' link #19431

Merged
merged 3 commits into from
May 24, 2023
Merged
Changes from all commits
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
24 changes: 14 additions & 10 deletions src/pages/DetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ const propTypes = {
/** Route params */
route: matchType.isRequired,

/** Session of currently logged in user */
session: PropTypes.shape({
email: PropTypes.string.isRequired,
/** Login list for the user that is signed in */
loginList: PropTypes.shape({
/** Date login was validated, used to show info indicator status */
validatedDate: PropTypes.string,

/** Field-specific server side errors keyed by microtime */
errorFields: PropTypes.objectOf(PropTypes.objectOf(PropTypes.string)),
}),

...withLocalizePropTypes,
Expand All @@ -59,9 +63,7 @@ const propTypes = {
const defaultProps = {
// When opening someone else's profile (via deep link) before login, this is empty
personalDetails: {},
session: {
email: null,
},
loginList: {},
};

/**
Expand Down Expand Up @@ -113,6 +115,8 @@ class DetailsPage extends React.PureComponent {
const phoneNumber = getPhoneNumber(details);
const phoneOrEmail = isSMSLogin ? getPhoneNumber(details) : details.login;

const isCurrentUser = _.keys(this.props.loginList).includes(details.login);

return (
<ScreenWrapper>
<FullPageNotFoundView shouldShow={_.isEmpty(login)}>
Expand Down Expand Up @@ -187,7 +191,7 @@ class DetailsPage extends React.PureComponent {
) : null}
{shouldShowLocalTime && <AutoUpdateTime timezone={details.timezone} />}
</View>
{details.login !== this.props.session.email && (
{!isCurrentUser && (
<MenuItem
title={`${this.props.translate('common.message')}${details.displayName}`}
icon={Expensicons.ChatBubble}
Expand All @@ -211,11 +215,11 @@ DetailsPage.defaultProps = defaultProps;
export default compose(
withLocalize,
withOnyx({
session: {
key: ONYXKEYS.SESSION,
},
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS,
},
loginList: {
key: ONYXKEYS.LOGIN_LIST,
},
}),
)(DetailsPage);