diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 58310b47dc84..7b0fd560ffe1 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -447,6 +447,17 @@ function isThreadParent(reportAction) { return reportAction && reportAction.childReportID && reportAction.childReportID !== 0; } +/** + * Returns true if reportAction is the first chat preview of a Thread + * + * @param {Object} reportAction + * @param {String} reportID + * @returns {Boolean} + */ +function isThreadFirstChat(reportAction, reportID) { + return !_.isUndefined(reportAction.childReportID) && reportAction.childReportID.toString() === reportID; +} + /** * Get either the policyName or domainName the chat is tied to * @param {Object} report @@ -2082,6 +2093,7 @@ export { getWorkspaceAvatar, isThread, isThreadParent, + isThreadFirstChat, shouldReportShowSubscript, isSettled, }; diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 9f95c0a8bf97..2b56094afc2b 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -114,7 +114,7 @@ export default [ Permissions.canUseThreads(betas) && type === CONTEXT_MENU_TYPES.REPORT_ACTION && reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && - (_.isUndefined(reportAction.childReportID) || reportAction.childReportID.toString() !== reportID), + !ReportUtils.isThreadFirstChat(reportAction, reportID), onPress: (closePopover, {reportAction, reportID}) => { Report.navigateToAndOpenChildReport(lodashGet(reportAction, 'childReportID', '0'), reportAction, reportID); if (closePopover) { diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index cd61292e18be..38b5bda6f713 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -249,7 +249,8 @@ class ReportActionItem extends Component { const reactions = _.get(this.props, ['action', 'message', 0, 'reactions'], []); const hasReactions = reactions.length > 0; - const shouldDisplayThreadReplies = (this.props.action.childCommenterCount || 0) > 0 && Permissions.canUseThreads(this.props.betas); + const shouldDisplayThreadReplies = + this.props.action.childCommenterCount && Permissions.canUseThreads(this.props.betas) && !ReportUtils.isThreadFirstChat(this.props.action, this.props.report.reportID); const oldestFourEmails = lodashGet(this.props.action, 'childOldestFourEmails', '').split(','); return (