From 4b210c6ea722405f0c1840d5c8e9309dc50b44bf Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 6 Aug 2024 11:07:11 +0700 Subject: [PATCH 1/3] fix: User can write and send a message onboarding tasks --- src/libs/ReportUtils.ts | 4 ++-- src/libs/actions/Report.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index cf9fcf68a800..6a5233043ab7 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5800,12 +5800,12 @@ function getChatByParticipants(newParticipantList: number[], reports: OnyxCollec const participantAccountIDs = Object.keys(report?.participants ?? {}); // Skip if it's not a 1:1 chat - if (!shouldIncludeGroupChats && !isOneOnOneChat(report)) { + if (!shouldIncludeGroupChats && !isOneOnOneChat(report) && !isSystemChat(report)) { return false; } // If we are looking for a group chat, then skip non-group chat report - if (shouldIncludeGroupChats && !isGroupChat(report)) { + if (shouldIncludeGroupChats && !isGroupChat(report) && !isSystemChat(report)) { return false; } diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 2a6ef8da9214..ff8d366c2bf0 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3346,6 +3346,7 @@ function completeOnboarding( }, isOptimisticReport: true, managerID: currentUserAccountID, + permissions: targetChatReport?.permissions, }, }, { From 8a221310f109e6bb756bdfa0b87b93652a85e3da Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 6 Aug 2024 15:04:11 +0700 Subject: [PATCH 2/3] fix: do not check system chat in group --- 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 6a5233043ab7..71ee7ef8bfdc 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5805,7 +5805,7 @@ function getChatByParticipants(newParticipantList: number[], reports: OnyxCollec } // If we are looking for a group chat, then skip non-group chat report - if (shouldIncludeGroupChats && !isGroupChat(report) && !isSystemChat(report)) { + if (shouldIncludeGroupChats && !isGroupChat(report)) { return false; } From 9da61418df7b3767c96f968a2a3d2004e7c0ff92 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Wed, 7 Aug 2024 11:57:11 +0700 Subject: [PATCH 3/3] fix mWeb bug --- src/libs/actions/Report.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index ff8d366c2bf0..e28af2e6e439 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3231,6 +3231,9 @@ function completeOnboarding( const isAccountIDOdd = AccountUtils.isAccountIDOddNumber(currentUserAccountID ?? 0); const targetEmail = isAccountIDOdd ? CONST.EMAIL.NOTIFICATIONS : CONST.EMAIL.CONCIERGE; + // If the target report isn't opened, the permission field will not exist. So we should add the fallback permission for task report + const fallbackPermission = isAccountIDOdd ? [CONST.REPORT.PERMISSIONS.READ] : [CONST.REPORT.PERMISSIONS.READ, CONST.REPORT.PERMISSIONS.WRITE]; + const actorAccountID = PersonalDetailsUtils.getAccountIDsByLogins([targetEmail])[0]; const targetChatReport = ReportUtils.getChatByParticipants([actorAccountID, currentUserAccountID]); const {reportID: targetChatReportID = '', policyID: targetChatPolicyID = ''} = targetChatReport ?? {}; @@ -3346,7 +3349,7 @@ function completeOnboarding( }, isOptimisticReport: true, managerID: currentUserAccountID, - permissions: targetChatReport?.permissions, + permissions: targetChatReport?.permissions ?? fallbackPermission, }, }, {