Skip to content

Commit

Permalink
Merge pull request #44560 from truph01/fix/43404
Browse files Browse the repository at this point in the history
Fix: User is able to leave public room when user is not logged in
  • Loading branch information
MonilBhavsar authored Jul 11, 2024
2 parents a91b7f8 + 23ad662 commit a19ef98
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import AccountUtils from './AccountUtils';
import * as IOU from './actions/IOU';
import * as PolicyActions from './actions/Policy/Policy';
import * as store from './actions/ReimbursementAccount/store';
import * as SessionUtils from './actions/Session';
import * as CurrencyUtils from './CurrencyUtils';
import DateUtils from './DateUtils';
import {hasValidDraftComment} from './DraftCommentUtils';
Expand Down Expand Up @@ -6934,6 +6935,10 @@ function canJoinChat(report: OnyxInputOrEntry<Report>, parentReportAction: OnyxI
* Whether the user can leave a report
*/
function canLeaveChat(report: OnyxEntry<Report>, policy: OnyxEntry<Policy>): boolean {
if (isPublicRoom(report) && SessionUtils.isAnonymousUser()) {
return false;
}

if (report?.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) {
return false;
}
Expand Down

0 comments on commit a19ef98

Please sign in to comment.