diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index e79ba13becd4..2ae3babc5be7 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -5035,7 +5035,6 @@ function buildOptimisticSelfDMReport(created: string): Report { type: CONST.REPORT.TYPE.CHAT, chatType: CONST.REPORT.CHAT_TYPE.SELF_DM, isOwnPolicyExpenseChat: false, - isPinned: true, lastActorAccountID: 0, lastMessageHtml: '', lastMessageText: undefined, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 5946903d099c..43a6c6d8a18b 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -635,7 +635,6 @@ function getOptionData({ result.isIOUReportOwner = isIOUOwnedByCurrentUser(result as Report); if (isJoinRequestInAdminRoom(report)) { - result.isPinned = true; result.isUnread = true; result.brickRoadIndicator = CONST.BRICK_ROAD_INDICATOR_STATUS.INFO; } diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 559da22369fb..bf49acda39c4 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -4089,23 +4089,7 @@ function prepareOnboardingOnyxData( const selfDMReportID = findSelfDMReportID(); let selfDMReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${selfDMReportID}`]; let createdAction: ReportAction; - if (selfDMReport) { - optimisticData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${selfDMReportID}`, - value: { - isPinned: true, - }, - }); - - failureData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${selfDMReportID}`, - value: { - isPinned: selfDMReport?.isPinned, - }, - }); - } else { + if (!selfDMReport) { const currentTime = DateUtils.getDBTime(); selfDMReport = buildOptimisticSelfDMReport(currentTime); createdAction = buildOptimisticCreatedReportAction(currentUserEmail ?? '', currentTime); diff --git a/tests/unit/SidebarUtilsTest.ts b/tests/unit/SidebarUtilsTest.ts index b5c15898b5d2..5d5ade290618 100644 --- a/tests/unit/SidebarUtilsTest.ts +++ b/tests/unit/SidebarUtilsTest.ts @@ -195,6 +195,42 @@ describe('SidebarUtils', () => { expect(result).toBeNull(); }); + + it('returns isPinned true only when report.isPinned is true', () => { + const MOCK_REPORT_PINNED: Report = { + reportID: '1', + isPinned: true, + }; + const MOCK_REPORT_UNPINNED: Report = { + reportID: '2', + isPinned: false, + }; + + const optionDataPinned = SidebarUtils.getOptionData({ + report: MOCK_REPORT_PINNED, + reportNameValuePairs: {}, + reportActions: {}, + personalDetails: {}, + preferredLocale: CONST.LOCALES.DEFAULT, + policy: undefined, + parentReportAction: undefined, + hasViolations: false, + }); + + const optionDataUnpinned = SidebarUtils.getOptionData({ + report: MOCK_REPORT_UNPINNED, + reportNameValuePairs: {}, + reportActions: {}, + personalDetails: {}, + preferredLocale: CONST.LOCALES.DEFAULT, + policy: undefined, + parentReportAction: undefined, + hasViolations: false, + }); + + expect(optionDataPinned?.isPinned).toBe(true); + expect(optionDataUnpinned?.isPinned).toBe(false); + }); }); describe('shouldShowRedBrickRoad', () => {