Skip to content

Commit

Permalink
Don't show on thread preview (first chat in thread)
Browse files Browse the repository at this point in the history
  • Loading branch information
grgia committed May 12, 2023
1 parent 67d6171 commit 30f5eba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2082,6 +2093,7 @@ export {
getWorkspaceAvatar,
isThread,
isThreadParent,
isThreadFirstChat,
shouldReportShowSubscript,
isSettled,
};
2 changes: 1 addition & 1 deletion src/pages/home/report/ContextMenu/ContextMenuActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion src/pages/home/report/ReportActionItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 30f5eba

Please sign in to comment.