Skip to content

Commit

Permalink
Merge pull request #40511 from Expensify/cmartins-fixQuickActionReport
Browse files Browse the repository at this point in the history
[CP Staging] Remove quick action report when leaving group chat

(cherry picked from commit 0d595b3)
  • Loading branch information
thienlnam authored and OSBotify committed Apr 19, 2024
1 parent 0c9975d commit e4a1a6e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import type {
PersonalDetails,
PersonalDetailsList,
PolicyReportField,
QuickAction,
RecentlyUsedReportFields,
ReportActionReactions,
ReportMetadata,
Expand Down Expand Up @@ -219,6 +220,12 @@ Onyx.connect({
callback: (val) => (allRecentlyUsedReportFields = val),
});

let quickAction: OnyxEntry<QuickAction> = {};
Onyx.connect({
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
callback: (val) => (quickAction = val),
});

function clearGroupChat() {
Onyx.set(ONYXKEYS.NEW_GROUP_CHAT_DRAFT, null);
}
Expand Down Expand Up @@ -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});
}
Expand Down

0 comments on commit e4a1a6e

Please sign in to comment.