diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index fdd255f05006..f3c9e67d79db 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -2,6 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import _ from 'underscore'; import lodashGet from 'lodash/get'; +import lodashCloneDeep from 'lodash/cloneDeep'; import * as Report from '../../../libs/actions/Report'; import reportActionPropTypes from './reportActionPropTypes'; import Visibility from '../../../libs/Visibility'; @@ -218,6 +219,21 @@ class ReportActionsView extends React.Component { }); } + // If the last unread message was deleted, remove the *New* green marker and the *New Messages* notification at scroll just as the deletion starts. + if ( + ReportUtils.isUnread(this.props.report) && + this.props.reportActions.length > 0 && + this.props.reportActions[0].pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && + !this.props.network.isOffline + ) { + const reportActionsWithoutPendingOne = lodashCloneDeep(this.props.reportActions); + reportActionsWithoutPendingOne.shift(); + const newMarkerReportActionID = ReportUtils.getNewMarkerReportActionID(this.props.report, reportActionsWithoutPendingOne); + if (newMarkerReportActionID !== this.state.newMarkerReportActionID) { + this.setState({newMarkerReportActionID}); + } + } + // Checks to see if a report comment has been manually "marked as unread". All other times when the lastReadTime // changes it will be because we marked the entire report as read. const didManuallyMarkReportAsUnread = prevProps.report.lastReadTime !== this.props.report.lastReadTime && ReportUtils.isUnread(this.props.report);