From ec29676ec96656545695ec76c22dc16130fc86da Mon Sep 17 00:00:00 2001 From: daledah Date: Fri, 21 Feb 2025 00:01:50 +0700 Subject: [PATCH 1/4] fix: keep private room name when leaving --- src/libs/actions/Report.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index d9a5cf8f2bc61..27d7f86fac95e 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3129,10 +3129,9 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal }, }, } - : Object.keys(report).reduce>((acc, key) => { - acc[key] = null; - return acc; - }, {}), + : { + reportName: report.reportName, + }, }, ]; From 2063de8082cd8d98314898c4993809dd3a6445ee Mon Sep 17 00:00:00 2001 From: daledah Date: Mon, 24 Feb 2025 10:39:35 +0700 Subject: [PATCH 2/4] fix: use Onyx.set method to clear all report data --- src/libs/actions/Report.ts | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index aa2973bdab8c7..c740ab343c456 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3117,24 +3117,26 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal }, ]; - const successData: OnyxUpdate[] = [ - { + const successData: OnyxUpdate[] = []; + if (isWorkspaceMemberLeavingWorkspaceRoom || isChatThread) { + successData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, - value: - isWorkspaceMemberLeavingWorkspaceRoom || isChatThread - ? { - participants: { - [currentUserAccountID]: { - notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, - }, - }, - } - : { - reportName: report.reportName, - }, - }, - ]; + value: { + participants: { + [currentUserAccountID]: { + notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, + }, + }, + }, + }); + } else { + successData.push({ + onyxMethod: Onyx.METHOD.SET, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: {reportName: report.reportName}, + }); + } const failureData: OnyxUpdate[] = [ { From f9376d10a94a89a22fbd5c959a0a0d6c638125d5 Mon Sep 17 00:00:00 2001 From: daledah Date: Tue, 25 Feb 2025 10:10:22 +0700 Subject: [PATCH 3/4] refactor: add explaination comment --- src/libs/actions/Report.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index c740ab343c456..035d9a9d25b07 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3131,6 +3131,8 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal }, }); } else { + // use Onyx.set method to remove all other key values besides reportName to prevent showing room name as random numbers. + // See https://github.com/Expensify/App/issues/55676 for more information. successData.push({ onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, From d20e5daaa98dc413672e0c947d1a40d75a3ade78 Mon Sep 17 00:00:00 2001 From: daledah Date: Tue, 25 Feb 2025 23:20:08 +0700 Subject: [PATCH 4/4] Update src/libs/actions/Report.ts Co-authored-by: Pavlo Tsimura --- src/libs/actions/Report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 035d9a9d25b07..d6910ebcb26b4 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -3131,7 +3131,7 @@ function leaveRoom(reportID: string, isWorkspaceMemberLeavingWorkspaceRoom = fal }, }); } else { - // use Onyx.set method to remove all other key values besides reportName to prevent showing room name as random numbers. + // Use the Onyx.set method to remove all other key values except reportName to prevent showing the room name as random numbers after leaving it. // See https://github.com/Expensify/App/issues/55676 for more information. successData.push({ onyxMethod: Onyx.METHOD.SET,