From cffd8ed378c292cb5ecd6a6b7acffedab45b04cc Mon Sep 17 00:00:00 2001
From: Luke Donahue <luke@expensify.com>
Date: Thu, 9 Jun 2022 13:04:24 +0200
Subject: [PATCH 1/2] Add a const

---
 src/CONST.js | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/CONST.js b/src/CONST.js
index 5b1b82da5904..4afd615db61a 100755
--- a/src/CONST.js
+++ b/src/CONST.js
@@ -384,6 +384,7 @@ const CONST = {
 
     PUSHER: {
         PRIVATE_USER_CHANNEL_PREFIX: 'private-encrypted-user-accountID-',
+        PRIVATE_REPORT_CHANNEL_PREFIX: 'private-report-reportID-',
     },
 
     EMOJI_SPACER: 'SPACER',

From 35ce1c636ffab27ebfba4da033e1893e3d827396 Mon Sep 17 00:00:00 2001
From: Luke Donahue <luke@expensify.com>
Date: Thu, 9 Jun 2022 13:04:33 +0200
Subject: [PATCH 2/2] use that const everywhere

---
 src/libs/actions/Report.js  | 4 ++--
 src/libs/actions/User.js    | 4 ++--
 tests/actions/ReportTest.js | 6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js
index 1dd7a21b4685..41c4857b9437 100644
--- a/src/libs/actions/Report.js
+++ b/src/libs/actions/Report.js
@@ -720,7 +720,7 @@ function updateReportPinnedState(reportID, isPinned) {
  * @returns {String}
  */
 function getReportChannelName(reportID) {
-    return `private-report-reportID-${reportID}${CONFIG.PUSHER.SUFFIX}`;
+    return `${CONST.PUSHER.PRIVATE_REPORT_CHANNEL_PREFIX}${reportID}${CONFIG.PUSHER.SUFFIX}`;
 }
 
 /**
@@ -732,7 +732,7 @@ function subscribeToUserEvents() {
         return;
     }
 
-    const pusherChannelName = `private-encrypted-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;
+    const pusherChannelName = `${CONST.PUSHER.PRIVATE_USER_CHANNEL_PREFIX}${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;
     if (Pusher.isSubscribed(pusherChannelName) || Pusher.isAlreadySubscribing(pusherChannelName)) {
         return;
     }
diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js
index cc7b282f3029..97b24d841a2c 100644
--- a/src/libs/actions/User.js
+++ b/src/libs/actions/User.js
@@ -302,7 +302,7 @@ function subscribeToUserEvents() {
         return;
     }
 
-    const pusherChannelName = `private-encrypted-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;
+    const pusherChannelName = `${CONST.PUSHER.PRIVATE_USER_CHANNEL_PREFIX}${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;
 
     // Receive any relevant Onyx updates from the server
     PusherUtils.subscribeToPrivateUserChannelEvent(Pusher.TYPE.ONYX_API_UPDATE, currentUserAccountID, (pushJSON) => {
@@ -355,7 +355,7 @@ function subscribeToExpensifyCardUpdates() {
         return;
     }
 
-    const pusherChannelName = `private-encrypted-user-accountID-${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;
+    const pusherChannelName = `${CONST.PUSHER.PRIVATE_USER_CHANNEL_PREFIX}${currentUserAccountID}${CONFIG.PUSHER.SUFFIX}`;
 
     // Handle Expensify Card approval flow updates
     Pusher.subscribe(pusherChannelName, Pusher.TYPE.EXPENSIFY_CARD_UPDATE, (pushJSON) => {
diff --git a/tests/actions/ReportTest.js b/tests/actions/ReportTest.js
index 7d1c569603ed..8a9e944a6b74 100644
--- a/tests/actions/ReportTest.js
+++ b/tests/actions/ReportTest.js
@@ -43,7 +43,7 @@ describe('actions/Report', () => {
     afterEach(() => {
         // Unsubscribe from account channel after each test since we subscribe in the function
         // subscribeToUserEvents and we don't want duplicate event subscriptions.
-        Pusher.unsubscribe(`private-encrypted-user-accountID-1${CONFIG.PUSHER.SUFFIX}`);
+        Pusher.unsubscribe(`${CONST.PUSHER.PRIVATE_USER_CHANNEL_PREFIX}1${CONFIG.PUSHER.SUFFIX}`);
     });
 
     it('should store a new report action in Onyx when reportComment event is handled via Pusher', () => {
@@ -104,7 +104,7 @@ describe('actions/Report', () => {
             .then(() => {
                 // We subscribed to the Pusher channel above and now we need to simulate a reportComment action
                 // Pusher event so we can verify that action was handled correctly and merged into the reportActions.
-                const channel = Pusher.getChannel(`private-encrypted-user-accountID-1${CONFIG.PUSHER.SUFFIX}`);
+                const channel = Pusher.getChannel(`${CONST.PUSHER.PRIVATE_USER_CHANNEL_PREFIX}1${CONFIG.PUSHER.SUFFIX}`);
                 channel.emit(Pusher.TYPE.REPORT_COMMENT, {
                     reportID: REPORT_ID,
                     reportAction: {...REPORT_ACTION, clientID},
@@ -158,7 +158,7 @@ describe('actions/Report', () => {
             .then(() => {
                 // We subscribed to the Pusher channel above and now we need to simulate a reportTogglePinned
                 // Pusher event so we can verify that pinning was handled correctly and merged into the report.
-                const channel = Pusher.getChannel(`private-encrypted-user-accountID-1${CONFIG.PUSHER.SUFFIX}`);
+                const channel = Pusher.getChannel(`${CONST.PUSHER.PRIVATE_USER_CHANNEL_PREFIX}1${CONFIG.PUSHER.SUFFIX}`);
                 channel.emit(Pusher.TYPE.REPORT_TOGGLE_PINNED, {
                     reportID: REPORT_ID,
                     isPinned: true,
