Skip to content

Commit

Permalink
Merge pull request #18393 from Expensify/jasper-deprecateDefaultRooms…
Browse files Browse the repository at this point in the history
…BetaExceptForDomainRooms

Deprecate the default rooms beta for #admins and #announce rooms
  • Loading branch information
jasperhuangg authored May 5, 2023
2 parents 5f649d5 + cd1c664 commit bdb2369
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/libs/Navigation/AppNavigator/MainDrawerNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', '');
Expand Down
1 change: 0 additions & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,6 @@ function getMemberInviteOptions(
return getOptions([], personalDetails, {
betas,
searchInputValue: searchValue.trim(),
excludeDefaultRooms: true,
includePersonalDetails: true,
excludeLogins,
sortPersonalDetailsByAlphaAsc: false,
Expand Down
17 changes: 9 additions & 8 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,13 @@ function isConciergeChatReport(report) {

/**
* @param {Record<String, {lastReadTime, reportID}>|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.
Expand All @@ -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;
Expand Down Expand Up @@ -1506,8 +1507,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;
}

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/SidebarFilterTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
});
});

Expand Down

0 comments on commit bdb2369

Please sign in to comment.