Skip to content

Commit

Permalink
Allow navigating to public announce rooms as the initial report after…
Browse files Browse the repository at this point in the history
… signing in/signing up
  • Loading branch information
jasperhuangg committed Apr 28, 2023
1 parent f8acfae commit e57478a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,17 @@ function isPublicRoom(report) {
return visibility === CONST.REPORT.VISIBILITY.PUBLIC || visibility === CONST.REPORT.VISIBILITY.PUBLIC_ANNOUNCE;
}

/**
* Whether the provided report is a public announce room
* @param {Object} report
* @param {String} report.visibility
* @returns {Boolean}
*/
function isPublicAnnounceRoom(report) {
const visibility = lodashGet(report, 'visibility', '');
return visibility === CONST.REPORT.VISIBILITY.PUBLIC_ANNOUNCE;
}

/**
* Get the policy type from a given report
* @param {Object} report
Expand Down Expand Up @@ -288,7 +299,9 @@ function findLastAccessedReport(reports, ignoreDefaultRooms, policies, openOnAdm
let sortedReports = sortReportsByLastRead(reports);

if (ignoreDefaultRooms) {
sortedReports = _.filter(sortedReports, report => !isDefaultRoom(report)
// We allow public announce rooms to show as the last accessed report 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)
|| getPolicyType(report, policies) === CONST.POLICY.TYPE.FREE
|| hasExpensifyGuidesEmails(lodashGet(report, ['participants'], [])));
}
Expand Down Expand Up @@ -1707,7 +1720,7 @@ function canLeaveRoom(report, isPolicyMember) {
|| _.isEmpty(report.chatType)) { // DM chats don't have a chatType
return false;
}
} else if (report.visibility === CONST.REPORT.VISIBILITY.PUBLIC_ANNOUNCE && isPolicyMember) {
} else if (isPublicAnnounceRoom(report) && isPolicyMember) {
return false;
}
return true;
Expand Down Expand Up @@ -1758,6 +1771,7 @@ export {
isArchivedRoom,
isPolicyExpenseChatAdmin,
isPublicRoom,
isPublicAnnounceRoom,
isConciergeChatReport,
isCurrentUserTheOnlyParticipant,
hasAutomatedExpensifyEmails,
Expand Down

0 comments on commit e57478a

Please sign in to comment.