Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 2 additions & 7 deletions src/libs/reportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import _ from 'underscore';
import Str from 'expensify-common/lib/str';
import lodashGet from 'lodash/get';
import Onyx from 'react-native-onyx';
import moment from 'moment';
import ONYXKEYS from '../ONYXKEYS';
import CONST from '../CONST';

Expand Down Expand Up @@ -211,23 +210,19 @@ function hasExpensifyEmails(emails) {
/**
* Whether the time row should be shown for a report.
* @param {Array<Object>} personalDetails
* @param {Object} myPersonalDetails
* @param {Object} report
* @return {Boolean}
*/
function canShowReportRecipientLocalTime(personalDetails, myPersonalDetails, report) {
function canShowReportRecipientLocalTime(personalDetails, report) {
const reportParticipants = lodashGet(report, 'participants', []);
const hasMultipleParticipants = reportParticipants.length > 1;
const reportRecipient = personalDetails[reportParticipants[0]];
const currentUserTimezone = lodashGet(myPersonalDetails, 'timezone', CONST.DEFAULT_TIME_ZONE);
const reportRecipientTimezone = lodashGet(reportRecipient, 'timezone', CONST.DEFAULT_TIME_ZONE);
return !hasExpensifyEmails(reportParticipants)
&& !hasMultipleParticipants
&& reportRecipient
&& reportRecipientTimezone
&& currentUserTimezone.selected
&& reportRecipientTimezone.selected
&& moment().tz(currentUserTimezone.selected).utcOffset() !== moment().tz(reportRecipientTimezone.selected).utcOffset();
&& reportRecipientTimezone.selected;
}

/**
Expand Down
12 changes: 2 additions & 10 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import * as ReportUtils from '../../../libs/reportUtils';
import ReportActionComposeFocusManager from '../../../libs/ReportActionComposeFocusManager';
import Text from '../../../components/Text';
import {participantPropTypes} from '../sidebar/optionPropTypes';
import currentUserPersonalDetailsPropsTypes from '../../settings/Profile/currentUserPersonalDetailsPropsTypes';
import ParticipantLocalTime from './ParticipantLocalTime';
import {withNetwork, withPersonalDetails} from '../../../components/OnyxProvider';
import DateUtils from '../../../libs/DateUtils';
Expand Down Expand Up @@ -64,9 +63,6 @@ const propTypes = {
isVisible: PropTypes.bool,
}),

/** The personal details of the person who is logged in */
myPersonalDetails: PropTypes.shape(currentUserPersonalDetailsPropsTypes),

/** Personal details of all the users */
personalDetails: PropTypes.objectOf(participantPropTypes),

Expand Down Expand Up @@ -112,7 +108,6 @@ const defaultProps = {
network: {isOffline: false},
blockedFromConcierge: {},
personalDetails: {},
myPersonalDetails: {},
};

class ReportActionCompose extends React.Component {
Expand Down Expand Up @@ -391,15 +386,15 @@ class ReportActionCompose extends React.Component {

render() {
// Waiting until ONYX variables are loaded before displaying the component
if (_.isEmpty(this.props.personalDetails) || _.isEmpty(this.props.myPersonalDetails)) {
if (_.isEmpty(this.props.personalDetails)) {
return null;
}

const reportParticipants = lodashGet(this.props.report, 'participants', []);
const hasMultipleParticipants = reportParticipants.length > 1;
const hasExcludedIOUEmails = lodashIntersection(reportParticipants, CONST.EXPENSIFY_EMAILS).length > 0;
const reportRecipient = this.props.personalDetails[reportParticipants[0]];
const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(this.props.personalDetails, this.props.myPersonalDetails, this.props.report);
const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(this.props.personalDetails, this.props.report);

// Prevents focusing and showing the keyboard while the drawer is covering the chat.
const isComposeDisabled = this.props.isDrawerOpen && this.props.isSmallScreenWidth;
Expand Down Expand Up @@ -632,9 +627,6 @@ export default compose(
modal: {
key: ONYXKEYS.MODAL,
},
myPersonalDetails: {
key: ONYXKEYS.MY_PERSONAL_DETAILS,
},
blockedFromConcierge: {
key: ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE,
},
Expand Down
10 changes: 1 addition & 9 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import Performance from '../../../libs/Performance';
import * as ReportUtils from '../../../libs/reportUtils';
import ONYXKEYS from '../../../ONYXKEYS';
import {withPersonalDetails} from '../../../components/OnyxProvider';
import currentUserPersonalDetailsPropsTypes from '../../settings/Profile/currentUserPersonalDetailsPropsTypes';
import {participantPropTypes} from '../sidebar/optionPropTypes';
import EmojiPicker from '../../../components/EmojiPicker';
import * as EmojiPickerAction from '../../../libs/actions/EmojiPickerAction';
Expand Down Expand Up @@ -74,9 +73,6 @@ const propTypes = {
/** Are we loading more report actions? */
isLoadingReportActions: PropTypes.bool,

/** The personal details of the person who is logged in */
myPersonalDetails: PropTypes.shape(currentUserPersonalDetailsPropsTypes),

/** Personal details of all the users */
personalDetails: PropTypes.objectOf(participantPropTypes),

Expand All @@ -95,7 +91,6 @@ const defaultProps = {
session: {},
isLoadingReportActions: false,
personalDetails: {},
myPersonalDetails: {},
};

class ReportActionsView extends React.Component {
Expand Down Expand Up @@ -547,7 +542,7 @@ class ReportActionsView extends React.Component {
// Native mobile does not render updates flatlist the changes even though component did update called.
// To notify there something changes we can use extraData prop to flatlist
const extraData = (!this.props.isDrawerOpen && this.props.isSmallScreenWidth) ? this.props.report.newMarkerSequenceNumber : undefined;
const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(this.props.personalDetails, this.props.myPersonalDetails, this.props.report);
const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(this.props.personalDetails, this.props.report);

return (
<>
Expand Down Expand Up @@ -600,8 +595,5 @@ export default compose(
key: ONYXKEYS.IS_LOADING_REPORT_ACTIONS,
initWithStoredValues: false,
},
myPersonalDetails: {
key: ONYXKEYS.MY_PERSONAL_DETAILS,
},
}),
)(ReportActionsView);