From e4a1a6e7d4de5aefff840573865c252294d76b6c Mon Sep 17 00:00:00 2001 From: Jack Nam <30609178+thienlnam@users.noreply.github.com> Date: Fri, 19 Apr 2024 10:19:37 -0700 Subject: [PATCH] Merge pull request #40511 from Expensify/cmartins-fixQuickActionReport [CP Staging] Remove quick action report when leaving group chat (cherry picked from commit 0d595b3814087c9806dd6757b0543eb46969c6f0) --- src/libs/actions/Report.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 77c90d83a52c..bf0d617905a3 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -82,6 +82,7 @@ import type { PersonalDetails, PersonalDetailsList, PolicyReportField, + QuickAction, RecentlyUsedReportFields, ReportActionReactions, ReportMetadata, @@ -219,6 +220,12 @@ Onyx.connect({ callback: (val) => (allRecentlyUsedReportFields = val), }); +let quickAction: OnyxEntry = {}; +Onyx.connect({ + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + callback: (val) => (quickAction = val), +}); + function clearGroupChat() { Onyx.set(ONYXKEYS.NEW_GROUP_CHAT_DRAFT, null); } @@ -2449,6 +2456,15 @@ function leaveGroupChat(reportID: string) { value: null, }, ]; + // Clean up any quick actions for the report we're leaving from + if (quickAction?.chatReportID?.toString() === reportID) { + optimisticData.push({ + onyxMethod: Onyx.METHOD.SET, + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + value: null, + }); + } + navigateToMostRecentReport(report); API.write(WRITE_COMMANDS.LEAVE_GROUP_CHAT, {reportID}, {optimisticData}); }