diff --git a/src/components/LHNOptionsList/OptionRowLHN.js b/src/components/LHNOptionsList/OptionRowLHN.js index 51dd75f19bb1..9c2ced6d896c 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.js +++ b/src/components/LHNOptionsList/OptionRowLHN.js @@ -96,6 +96,7 @@ const OptionRowLHN = (props) => { const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor; const avatarTooltips = !optionItem.isChatRoom && !optionItem.isArchivedRoom ? _.pluck(optionItem.displayNamesWithTooltips, 'tooltip') : undefined; + const shouldShowGreenDotIndicator = optionItem.isUnreadWithMention || (optionItem.hasOutstandingIOU && !optionItem.isIOUReportOwner); return ( { )} - {optionItem.hasOutstandingIOU && !optionItem.isIOUReportOwner && } + {shouldShowGreenDotIndicator && } {optionItem.isPinned && ( { addWorkspaceRoom: report.errorFields && report.errorFields.addWorkspaceRoom, }, lastReadTime: report.lastReadTime, + lastMentionedTime: report.lastMentionedTime, lastMessageText: report.lastMessageText, lastVisibleActionCreated: report.lastVisibleActionCreated, iouReportID: report.iouReportID, diff --git a/tests/actions/ReportTest.js b/tests/actions/ReportTest.js index 974708dcf4bf..b7379e3c6b42 100644 --- a/tests/actions/ReportTest.js +++ b/tests/actions/ReportTest.js @@ -235,7 +235,7 @@ describe('actions/Report', () => { }) .then(() => TestHelper.setPersonalDetails(USER_1_LOGIN, USER_1_ACCOUNT_ID)) .then(() => { - // When a Pusher event is handled for a new report comment + // When a Pusher event is handled for a new report comment that includes a mention of the current user reportActionCreatedDate = DateUtils.getDBTime(); channel.emit(Pusher.TYPE.ONYX_API_UPDATE, [ { @@ -247,6 +247,7 @@ describe('actions/Report', () => { lastMessageText: 'Comment 1', lastActorEmail: USER_2_LOGIN, lastVisibleActionCreated: reportActionCreatedDate, + lastMentionedTime: reportActionCreatedDate, lastReadTime: DateUtils.subtractMillisecondsFromDateTime(reportActionCreatedDate, 1), }, }, @@ -275,6 +276,9 @@ describe('actions/Report', () => { // Then the report will be unread expect(ReportUtils.isUnread(report)).toBe(true); + // And show a green dot for unread mentions in the LHN + expect(ReportUtils.isUnreadWithMention(report)).toBe(true); + // When the user visits the report jest.advanceTimersByTime(10); currentTime = DateUtils.getDBTime(); @@ -286,14 +290,18 @@ describe('actions/Report', () => { expect(ReportUtils.isUnread(report)).toBe(false); expect(moment.utc(report.lastReadTime).valueOf()).toBeGreaterThanOrEqual(moment.utc(currentTime).valueOf()); + // And no longer show the green dot for unread mentions in the LHN + expect(ReportUtils.isUnreadWithMention(report)).toBe(false); + // When the user manually marks a message as "unread" jest.advanceTimersByTime(10); Report.markCommentAsUnread(REPORT_ID, reportActionCreatedDate); return waitForPromisesToResolve(); }) .then(() => { - // Then the report will be unread + // Then the report will be unread and show the green dot for unread mentions in LHN expect(ReportUtils.isUnread(report)).toBe(true); + expect(ReportUtils.isUnreadWithMention(report)).toBe(true); expect(report.lastReadTime).toBe(DateUtils.subtractMillisecondsFromDateTime(reportActionCreatedDate, 1)); // When a new comment is added by the current user @@ -303,8 +311,9 @@ describe('actions/Report', () => { return waitForPromisesToResolve(); }) .then(() => { - // The report will be read and the lastReadTime updated + // The report will be read, the green dot for unread mentions will go away, and the lastReadTime updated expect(ReportUtils.isUnread(report)).toBe(false); + expect(ReportUtils.isUnreadWithMention(report)).toBe(false); expect(moment.utc(report.lastReadTime).valueOf()).toBeGreaterThanOrEqual(moment.utc(currentTime).valueOf()); expect(report.lastMessageText).toBe('Current User Comment 1');