diff --git a/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js b/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js index 9f582c2df9d6..c8fe97a24abe 100644 --- a/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js +++ b/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js @@ -58,14 +58,14 @@ const defaultProps = { * Get the most recently accessed report for the user * * @param {Object} reports - * @param {Boolean} [ignoreDefaultRooms] + * @param {Boolean} [ignoreDomainRooms] * @param {Object} policies * @param {Boolean} isFirstTimeNewExpensifyUser * @param {Boolean} openOnAdminRoom * @returns {Object} */ -const getInitialReportScreenParams = (reports, ignoreDefaultRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom) => { - const last = ReportUtils.findLastAccessedReport(reports, ignoreDefaultRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom); +const getInitialReportScreenParams = (reports, ignoreDomainRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom) => { + const last = ReportUtils.findLastAccessedReport(reports, ignoreDomainRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom); // Fallback to empty if for some reason reportID cannot be derived - prevents the app from crashing const reportID = lodashGet(last, 'reportID', ''); diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index b5944b58404d..af359e952da2 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -834,7 +834,6 @@ function getMemberInviteOptions( return getOptions([], personalDetails, { betas, searchInputValue: searchValue.trim(), - excludeDefaultRooms: true, includePersonalDetails: true, excludeLogins, sortPersonalDetailsByAlphaAsc: false, diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 90c5ac9643f0..ac9f8d9ad8bb 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -318,13 +318,13 @@ function isConciergeChatReport(report) { /** * @param {Record|Array<{lastReadTime, reportID}>} reports - * @param {Boolean} [ignoreDefaultRooms] + * @param {Boolean} [ignoreDomainRooms] * @param {Object} policies * @param {Boolean} isFirstTimeNewExpensifyUser * @param {Boolean} openOnAdminRoom * @returns {Object} */ -function findLastAccessedReport(reports, ignoreDefaultRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom = false) { +function findLastAccessedReport(reports, ignoreDomainRooms, policies, isFirstTimeNewExpensifyUser, openOnAdminRoom = false) { // If it's the user's first time using New Expensify, then they could either have: // - just a Concierge report, if so we'll return that // - their Concierge report, and a separate report that must have deeplinked them to the app before they created their account. @@ -339,16 +339,17 @@ function findLastAccessedReport(reports, ignoreDefaultRooms, policies, isFirstTi return _.find(sortedReports, report => !isConciergeChatReport(report)); } - if (ignoreDefaultRooms) { - // We allow public announce rooms to show as the last accessed report since we bypass the default rooms beta for them. + if (ignoreDomainRooms) { + // We allow public announce rooms, admins, and announce rooms through since we bypass the default rooms beta for them. // Check where ReportUtils.findLastAccessedReport is called in MainDrawerNavigator.js for more context. - sortedReports = _.filter(sortedReports, report => !isDefaultRoom(report) || isPublicAnnounceRoom(report) + // Domain rooms are now the only type of default room that are on the defaultRooms beta. + sortedReports = _.filter(sortedReports, report => !isDomainRoom(report) || getPolicyType(report, policies) === CONST.POLICY.TYPE.FREE || hasExpensifyGuidesEmails(lodashGet(report, ['participants'], []))); } let adminReport; - if (!ignoreDefaultRooms && openOnAdminRoom) { + if (openOnAdminRoom) { adminReport = _.find(sortedReports, (report) => { const chatType = getChatType(report); return chatType === CONST.REPORT.CHAT_TYPE.POLICY_ADMINS; @@ -1494,8 +1495,8 @@ function canSeeDefaultRoom(report, policies, betas) { return true; } - // Include any public announce rooms, since they could include people who should have access but we don't know to add to the beta - if (report.visibility === CONST.REPORT.VISIBILITY.PUBLIC_ANNOUNCE) { + // Include any admins and announce rooms, since only non partner-managed domain rooms are on the beta now. + if (isAdminRoom(report) || isAnnounceRoom(report)) { return true; } diff --git a/tests/unit/SidebarFilterTest.js b/tests/unit/SidebarFilterTest.js index a393199f2d4e..c45a5e33bf65 100644 --- a/tests/unit/SidebarFilterTest.js +++ b/tests/unit/SidebarFilterTest.js @@ -167,11 +167,11 @@ describe('Sidebar', () => { [`${ONYXKEYS.COLLECTION.REPORT}${report3.reportID}`]: report3, })) - // Then no reports are rendered in the LHN + // Then all non-domain rooms are rendered in the LHN .then(() => { const hintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); const optionRows = screen.queryAllByAccessibilityHint(hintText); - expect(optionRows).toHaveLength(0); + expect(optionRows).toHaveLength(2); }) // When the user is added to the default policy rooms beta and the sidebar re-renders @@ -222,11 +222,11 @@ describe('Sidebar', () => { // When the policy is a paid policy .then(() => Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policy.policyID}`, {type: CONST.POLICY.TYPE.CORPORATE})) - // Then the report is not rendered in the LHN + // Then the report is still rendered in the LHN .then(() => { const hintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); const optionRows = screen.queryAllByAccessibilityHint(hintText); - expect(optionRows).toHaveLength(0); + expect(optionRows).toHaveLength(1); }); });