From a083ff87829a7b2f7fca40e55cd30fcc049385a4 Mon Sep 17 00:00:00 2001 From: Neil Marcellini Date: Fri, 14 Jan 2022 12:10:37 -0800 Subject: [PATCH 1/4] Prevent default rooms from being filtered out --- src/libs/OptionsListUtils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 4dc9af374968..17984bdbe36e 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -395,7 +395,8 @@ function getOptions(reports, personalDetails, activeReportID, { const logins = lodashGet(report, ['participants'], []); // Report data can sometimes be incomplete. If we have no logins or reportID then we will skip this entry. - if (!report || !report.reportID || (_.isEmpty(logins) && !ReportUtils.isChatRoom(report))) { + const shouldFilterNoParticipants = _.isEmpty(logins) && !ReportUtils.isChatRoom(report) && !ReportUtils.isDefaultRoom(report); + if (!report || !report.reportID || shouldFilterNoParticipants) { return; } @@ -405,7 +406,7 @@ function getOptions(reports, personalDetails, activeReportID, { : ''; const reportContainsIOUDebt = iouReportOwner && iouReportOwner !== currentUserLogin; - const shouldFilterReportIfEmpty = !showReportsWithNoComments && report.lastMessageTimestamp === 0; + const shouldFilterReportIfEmpty = !showReportsWithNoComments && report.lastMessageTimestamp === 0 && !ReportUtils.isDefaultRoom(report); const shouldFilterReportIfRead = hideReadReports && report.unreadActionCount === 0; const shouldFilterReport = shouldFilterReportIfEmpty || shouldFilterReportIfRead; if (report.reportID !== activeReportID From 8773bcefe5fb59f9cbed5944b66c6d3bd320c32d Mon Sep 17 00:00:00 2001 From: Neil Marcellini Date: Wed, 19 Jan 2022 14:18:25 -0800 Subject: [PATCH 2/4] Fetch only the default reports on policy creation --- src/libs/actions/Policy.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index f71a681b24ce..6433c997e710 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -10,6 +10,7 @@ import * as Localize from '../Localize'; import Navigation from '../Navigation/Navigation'; import ROUTES from '../../ROUTES'; import * as OptionsListUtils from '../OptionsListUtils'; +import * as Report from './Report'; const allPolicies = {}; Onyx.connect({ @@ -111,6 +112,9 @@ function create(name = '') { } res = response; + // Fetch the default reports on the policy + Report.fetchChatReportsByIDs([response.policy.chatReportIDAdmins, response.policy.chatReportIDAnnounce]); + // We are awaiting this merge so that we can guarantee our policy is available to any React components connected to the policies collection before we navigate to a new route. return Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${response.policyID}`, { employeeList: getSimplifiedEmployeeList(response.policy.employeeList), From 3e15e90b4381c7db7ef24d8bf16ad20b5ee2ad4b Mon Sep 17 00:00:00 2001 From: Neil Marcellini Date: Fri, 21 Jan 2022 10:16:21 -0800 Subject: [PATCH 3/4] Update all reports when deleting a policy --- src/libs/actions/Policy.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index 6433c997e710..5dd0dd627051 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -162,7 +162,9 @@ function deletePolicy(policyID) { // Removing the workspace data from Onyx as well return Onyx.set(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, null); - }).then(() => { + }) + .then(() => Report.fetchAllReports(false, true)) + .then(() => { Navigation.dismissModal(); Navigation.navigate(ROUTES.HOME); return Promise.resolve(); From 173bc34671f9fa24c12bec5d6055798605a3d274 Mon Sep 17 00:00:00 2001 From: Neil Marcellini Date: Fri, 21 Jan 2022 10:17:10 -0800 Subject: [PATCH 4/4] Re-render the room name when it changes --- src/pages/home/sidebar/OptionRow.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pages/home/sidebar/OptionRow.js b/src/pages/home/sidebar/OptionRow.js index 6ce004650d6e..383542cc9347 100644 --- a/src/pages/home/sidebar/OptionRow.js +++ b/src/pages/home/sidebar/OptionRow.js @@ -275,5 +275,10 @@ export default withLocalize(memo(OptionRow, (prevProps, nextProps) => { return false; } + // Re-render when the text changes + if (prevProps.option.text !== nextProps.option.text) { + return false; + } + return true; }));