Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: notification count for empty reports #30133

Merged
merged 13 commits into from
Dec 5, 2023
10 changes: 10 additions & 0 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2992,6 +2992,15 @@ function buildTransactionThread(reportAction, moneyRequestReportID) {
);
}

/**
* @param {Object} report
* @returns {Boolean}
*/
function isEmptyReport(report) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this unused?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot about this. Removed now!

const lastVisibleMessage = ReportActionsUtils.getLastVisibleMessage(report.reportID);
return !report.lastMessageText && !report.lastMessageTranslationKey && !lastVisibleMessage.lastMessageText && !lastVisibleMessage.lastMessageTranslationKey;
}

/**
* @param {Object} report
* @returns {Boolean}
Expand Down Expand Up @@ -4000,6 +4009,7 @@ export {
navigateToDetailsPage,
generateReportID,
hasReportNameError,
isEmptyReport,
isUnread,
isUnreadWithMention,
buildOptimisticWorkspaceChats,
Expand Down
3 changes: 2 additions & 1 deletion src/libs/UnreadIndicatorUpdater/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _ from 'underscore';
import Onyx from 'react-native-onyx';
import Navigation from '../Navigation/Navigation';
import ONYXKEYS from '../../ONYXKEYS';
import updateUnread from './updateUnread/index';
import * as ReportUtils from '../ReportUtils';
Expand All @@ -8,7 +9,7 @@ Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (reportsFromOnyx) => {
const unreadReports = _.filter(reportsFromOnyx, ReportUtils.isUnread);
const unreadReports = _.filter(reportsFromOnyx, (report) => ReportUtils.isUnread(report) && ReportUtils.shouldReportBeInOptionList(report, Navigation.getTopmostReportId()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a short "why?" comment would increase the clarity of this fragment? We could just state that we want to keep notification count consistent with what can be accessed from the LHN list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

updateUnread(_.size(unreadReports));
},
});
Loading