From 6caf07ada2e1a4629174bf18356752c6eded1980 Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 28 Jun 2024 00:52:03 +0700 Subject: [PATCH 1/6] Fix: User is able to leave public room when user is not logged in --- src/libs/ReportUtils.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index cca52ac37c9d..5532c9a4a4f8 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -14,6 +14,7 @@ import {FallbackAvatar} from '@components/Icon/Expensicons'; import * as defaultGroupAvatars from '@components/Icon/GroupDefaultAvatars'; import * as defaultWorkspaceAvatars from '@components/Icon/WorkspaceDefaultAvatars'; import type {MoneyRequestAmountInputProps} from '@components/MoneyRequestAmountInput'; +import * as SessionUtils from '@userActions/Session'; import type {IOUAction, IOUType} from '@src/CONST'; import CONST from '@src/CONST'; import type {ParentNavigationSummaryParams, TranslationPaths} from '@src/languages/types'; @@ -6851,6 +6852,10 @@ function isNonAdminOrOwnerOfPolicyExpenseChat(report: OnyxInputOrEntry, * Whether the user can join a report */ function canJoinChat(report: OnyxInputOrEntry, parentReportAction: OnyxInputOrEntry, policy: OnyxInputOrEntry): boolean { + if (isPublicRoom(report as OnyxEntry) && SessionUtils.isAnonymousUser()) { + return true; + } + // We disabled thread functions for whisper action // So we should not show join option for existing thread on whisper message that has already been left, or manually leave it if (ReportActionsUtils.isWhisperAction(parentReportAction)) { @@ -6880,6 +6885,10 @@ function canJoinChat(report: OnyxInputOrEntry, parentReportAction: OnyxI * Whether the user can leave a report */ function canLeaveChat(report: OnyxEntry, policy: OnyxEntry): boolean { + if (isPublicRoom(report) && SessionUtils.isAnonymousUser()) { + return false; + } + if (report?.notificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN) { return false; } From c82de82574a120407341f2d71aeda8a8dfc89833 Mon Sep 17 00:00:00 2001 From: truph01 Date: Fri, 28 Jun 2024 01:07:04 +0700 Subject: [PATCH 2/6] Fix: Lint --- ios/Podfile.lock | 12 +++++++++--- src/libs/ReportUtils.ts | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 35dccc2de393..6a5306f892e6 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1243,7 +1243,13 @@ PODS: - react-native-config (1.5.0): - react-native-config/App (= 1.5.0) - react-native-config/App (1.5.0): - - React-Core + - RCT-Folly + - RCTRequired + - RCTTypeSafety + - React + - React-Codegen + - React-RCTFabric + - ReactCommon/turbomodule/core - react-native-document-picker (9.1.1): - RCT-Folly - RCTRequired @@ -2552,7 +2558,7 @@ SPEC CHECKSUMS: react-native-airship: 38e2596999242b68c933959d6145512e77937ac0 react-native-blob-util: 1ddace5234c62e3e6e4e154d305ad07ef686599b react-native-cameraroll: f373bebbe9f6b7c3fd2a6f97c5171cda574cf957 - react-native-config: 5330c8258265c1e5fdb8c009d2cabd6badd96727 + react-native-config: 5ce986133b07fc258828b20b9506de0e683efc1c react-native-document-picker: 8532b8af7c2c930f9e202aac484ac785b0f4f809 react-native-geolocation: f9e92eb774cb30ac1e099f34b3a94f03b4db7eb3 react-native-image-picker: f8a13ff106bcc7eb00c71ce11fdc36aac2a44440 @@ -2623,7 +2629,7 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 1394a316c7add37e619c48d7aa40b38b954bf055 - Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70 + Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 PODFILE CHECKSUM: d5e281e5370cb0211a104efd90eb5fa7af936e14 diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 5532c9a4a4f8..47572e1fed03 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -14,7 +14,6 @@ import {FallbackAvatar} from '@components/Icon/Expensicons'; import * as defaultGroupAvatars from '@components/Icon/GroupDefaultAvatars'; import * as defaultWorkspaceAvatars from '@components/Icon/WorkspaceDefaultAvatars'; import type {MoneyRequestAmountInputProps} from '@components/MoneyRequestAmountInput'; -import * as SessionUtils from '@userActions/Session'; import type {IOUAction, IOUType} from '@src/CONST'; import CONST from '@src/CONST'; import type {ParentNavigationSummaryParams, TranslationPaths} from '@src/languages/types'; @@ -52,6 +51,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'; From 9821b124ef6c3ee924e0484692f9816f0ecb9fd7 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 2 Jul 2024 10:26:48 +0700 Subject: [PATCH 3/6] Fix: Undo not related change --- ios/Podfile.lock | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 6a5306f892e6..5ad61a68f860 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1243,13 +1243,6 @@ PODS: - react-native-config (1.5.0): - react-native-config/App (= 1.5.0) - react-native-config/App (1.5.0): - - RCT-Folly - - RCTRequired - - RCTTypeSafety - - React - - React-Codegen - - React-RCTFabric - - ReactCommon/turbomodule/core - react-native-document-picker (9.1.1): - RCT-Folly - RCTRequired @@ -2558,7 +2551,7 @@ SPEC CHECKSUMS: react-native-airship: 38e2596999242b68c933959d6145512e77937ac0 react-native-blob-util: 1ddace5234c62e3e6e4e154d305ad07ef686599b react-native-cameraroll: f373bebbe9f6b7c3fd2a6f97c5171cda574cf957 - react-native-config: 5ce986133b07fc258828b20b9506de0e683efc1c + react-native-config: 5330c8258265c1e5fdb8c009d2cabd6badd96727 react-native-document-picker: 8532b8af7c2c930f9e202aac484ac785b0f4f809 react-native-geolocation: f9e92eb774cb30ac1e099f34b3a94f03b4db7eb3 react-native-image-picker: f8a13ff106bcc7eb00c71ce11fdc36aac2a44440 @@ -2629,7 +2622,7 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: 1394a316c7add37e619c48d7aa40b38b954bf055 - Yoga: 1b901a6d6eeba4e8a2e8f308f708691cdb5db312 + Yoga: 64cd2a583ead952b0315d5135bf39e053ae9be70 PODFILE CHECKSUM: d5e281e5370cb0211a104efd90eb5fa7af936e14 From 21c70e129d55e79501ffdb8154444ff675002973 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 2 Jul 2024 10:27:32 +0700 Subject: [PATCH 4/6] Fix: Undo not related change --- ios/Podfile.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 5ad61a68f860..35dccc2de393 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1243,6 +1243,7 @@ PODS: - react-native-config (1.5.0): - react-native-config/App (= 1.5.0) - react-native-config/App (1.5.0): + - React-Core - react-native-document-picker (9.1.1): - RCT-Folly - RCTRequired From ca800be77a1adc999ebbfa8ebd4067d0831a0648 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 2 Jul 2024 10:35:22 +0700 Subject: [PATCH 5/6] Fix: Typecheck --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 47572e1fed03..93c82b602d12 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6852,7 +6852,7 @@ function isNonAdminOrOwnerOfPolicyExpenseChat(report: OnyxInputOrEntry, * Whether the user can join a report */ function canJoinChat(report: OnyxInputOrEntry, parentReportAction: OnyxInputOrEntry, policy: OnyxInputOrEntry): boolean { - if (isPublicRoom(report as OnyxEntry) && SessionUtils.isAnonymousUser()) { + if (report && isPublicRoom(report) && SessionUtils.isAnonymousUser()) { return true; } From 23ad662d342c454db583c5febf1afce012717835 Mon Sep 17 00:00:00 2001 From: truph01 Date: Thu, 11 Jul 2024 04:48:39 +0700 Subject: [PATCH 6/6] Fix: Remove unsed changes --- src/libs/ReportUtils.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7a4c0d514e87..28f861efa757 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6902,10 +6902,6 @@ function isAdminOwnerApproverOrReportOwner(report: OnyxEntry, policy: On * Whether the user can join a report */ function canJoinChat(report: OnyxInputOrEntry, parentReportAction: OnyxInputOrEntry, policy: OnyxInputOrEntry): boolean { - if (report && isPublicRoom(report) && SessionUtils.isAnonymousUser()) { - return true; - } - // We disabled thread functions for whisper action // So we should not show join option for existing thread on whisper message that has already been left, or manually leave it if (ReportActionsUtils.isWhisperAction(parentReportAction)) {