Skip to content

Commit

Permalink
Merge pull request #5094 from Santhosh-Sellavel/Hide_Timezone_And_Cal…
Browse files Browse the repository at this point in the history
…l_Options_For_Expensify_Emails

Removed call option & timezone in report details page for automated accounts
  • Loading branch information
Jag96 authored Sep 14, 2021
2 parents 145eb96 + bd1d50b commit def9cb7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
12 changes: 11 additions & 1 deletion src/libs/reportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Str from 'expensify-common/lib/str';
import lodashGet from 'lodash/get';
import Onyx from 'react-native-onyx';
import ONYXKEYS from '../ONYXKEYS';
import CONST from '../CONST';
import CONST, {EXPENSIFY_EMAILS} from '../CONST';

let sessionEmail;
Onyx.connect({
Expand Down Expand Up @@ -152,6 +152,15 @@ function isConciergeChatReport(report) {
&& report.participants[0] === CONST.EMAIL.CONCIERGE;
}

/**
* Returns true if there is any automated expensify account in emails
* @param {Array} emails
* @returns {Boolean}
*/
function hasExpensifyEmails(emails) {
return _.intersection(emails, EXPENSIFY_EMAILS).length > 0;
}

export {
getReportParticipantsTitle,
isReportMessageAttachment,
Expand All @@ -163,4 +172,5 @@ export {
getDefaultRoomSubtitle,
isArchivedRoom,
isConciergeChatReport,
hasExpensifyEmails,
};
4 changes: 3 additions & 1 deletion src/pages/DetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import withLocalize, {withLocalizePropTypes} from '../components/withLocalize';
import compose from '../libs/compose';
import CommunicationsLink from '../components/CommunicationsLink';
import CONST from '../CONST';
import {hasExpensifyEmails} from '../libs/reportUtils';

const matchType = PropTypes.shape({
params: PropTypes.shape({
Expand Down Expand Up @@ -69,6 +70,7 @@ const DetailsPage = ({
const timezone = moment().tz(details.timezone.selected);
const GMTTime = `${timezone.toString().split(/[+-]/)[0].slice(-3)} ${timezone.zoneAbbr()}`;
const currentTime = Number.isNaN(Number(timezone.zoneAbbr())) ? timezone.zoneAbbr() : GMTTime;
const shouldShowLocalTime = !hasExpensifyEmails([details.login]);

return (
<ScreenWrapper>
Expand Down Expand Up @@ -126,7 +128,7 @@ const DetailsPage = ({
</Text>
</View>
) : null}
{details.timezone ? (
{shouldShowLocalTime && details.timezone ? (
<View style={[styles.mb6, styles.detailsPageSectionContainer]}>
<Text style={[styles.formLabel, styles.mb2]} numberOfLines={1}>
{translate('detailsPage.localTime')}
Expand Down
11 changes: 9 additions & 2 deletions src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import VideoChatButtonAndMenu from '../../components/VideoChatButtonAndMenu';
import IOUBadge from '../../components/IOUBadge';
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
import CONST from '../../CONST';
import {getDefaultRoomSubtitle, isDefaultRoom, isArchivedRoom} from '../../libs/reportUtils';
import {
getDefaultRoomSubtitle, isDefaultRoom, isArchivedRoom, hasExpensifyEmails,
} from '../../libs/reportUtils';
import Text from '../../components/Text';
import Tooltip from '../../components/Tooltip';

Expand Down Expand Up @@ -92,6 +94,11 @@ const HeaderView = (props) => {

const subtitle = getDefaultRoomSubtitle(props.report, props.policies);
const isConcierge = participants.length === 1 && participants.includes(CONST.EMAIL.CONCIERGE);
const isAutomatedExpensifyAccount = (participants.length === 1 && hasExpensifyEmails(participants));

// We hide the button when we are chatting with an automated Expensify account since it's not possible to contact
// these users via alternative means. It is possible to request a call with Concierge so we leave the option for them.
const shouldShowCallButton = isConcierge || !isAutomatedExpensifyAccount;

return (
<View style={[styles.appContentHeader]} nativeID="drag-area">
Expand Down Expand Up @@ -162,7 +169,7 @@ const HeaderView = (props) => {
<IOUBadge iouReportID={props.report.iouReportID} />
)}

<VideoChatButtonAndMenu isConcierge={isConcierge} />
{shouldShowCallButton && <VideoChatButtonAndMenu isConcierge={isConcierge} />}
<Tooltip text={props.report.isPinned ? props.translate('common.unPin') : props.translate('common.pin')}>
<Pressable
onPress={() => togglePinnedState(props.report)}
Expand Down
7 changes: 3 additions & 4 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import EmojiPickerMenu from './EmojiPickerMenu';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';
import withDrawerState from '../../../components/withDrawerState';
import getButtonState from '../../../libs/getButtonState';
import CONST, {EXCLUDED_IOU_EMAILS, EXPENSIFY_EMAILS} from '../../../CONST';
import CONST, {EXCLUDED_IOU_EMAILS} from '../../../CONST';
import canFocusInputOnScreenFocus from '../../../libs/canFocusInputOnScreenFocus';
import variables from '../../../styles/variables';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
Expand All @@ -52,7 +52,7 @@ import Navigation from '../../../libs/Navigation/Navigation';
import ROUTES from '../../../ROUTES';
import * as User from '../../../libs/actions/User';
import ReportActionPropTypes from './ReportActionPropTypes';
import {canEditReportAction, isArchivedRoom} from '../../../libs/reportUtils';
import {canEditReportAction, hasExpensifyEmails, isArchivedRoom} from '../../../libs/reportUtils';
import ReportActionComposeFocusManager from '../../../libs/ReportActionComposeFocusManager';
import Text from '../../../components/Text';
import {participantPropTypes} from '../sidebar/optionPropTypes';
Expand Down Expand Up @@ -459,12 +459,11 @@ class ReportActionCompose extends React.Component {
// eslint-disable-next-line no-unused-vars
const reportParticipants = lodashGet(this.props.report, 'participants', []);
const hasMultipleParticipants = reportParticipants.length > 1;
const hasExpensifyEmails = lodashIntersection(reportParticipants, EXPENSIFY_EMAILS).length > 0;
const hasExcludedIOUEmails = lodashIntersection(reportParticipants, EXCLUDED_IOU_EMAILS).length > 0;
const reportRecipient = this.props.personalDetails[reportParticipants[0]];
const currentUserTimezone = lodashGet(this.props.myPersonalDetails, 'timezone', CONST.DEFAULT_TIME_ZONE);
const reportRecipientTimezone = lodashGet(reportRecipient, 'timezone', CONST.DEFAULT_TIME_ZONE);
const shouldShowReportRecipientLocalTime = !hasExpensifyEmails
const shouldShowReportRecipientLocalTime = !hasExpensifyEmails(reportParticipants)
&& !hasMultipleParticipants
&& reportRecipient
&& reportRecipientTimezone
Expand Down

0 comments on commit def9cb7

Please sign in to comment.