diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index f191c1d06532..afedd308371c 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -595,9 +595,8 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails // some types of actions are filtered out for lastReportAction, in some cases we need to check the actual last action const lastOriginalReportAction = lastReportActions[reportID] ?? null; let lastMessageTextFromReport = ''; - const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); - if (ReportUtils.isArchivedRoom(report, reportNameValuePairs)) { + if (report?.private_isArchived) { const archiveReason = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing (ReportActionUtils.isClosedAction(lastOriginalReportAction) && ReportActionUtils.getOriginalMessage(lastOriginalReportAction)?.reason) || CONST.REPORT.ARCHIVE_REASON.DEFAULT; @@ -712,7 +711,6 @@ function createOption( isIOUReportOwner: null, iouReportAmount: 0, isChatRoom: false, - isArchivedRoom: false, shouldShowSubscript: false, isPolicyExpenseChat: false, isOwnPolicyExpenseChat: false, @@ -730,11 +728,11 @@ function createOption( let reportName; result.participantsList = personalDetailList; result.isOptimisticPersonalDetail = personalDetail?.isOptimisticPersonalDetail; - const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); if (report) { result.isChatRoom = ReportUtils.isChatRoom(report); result.isDefaultRoom = ReportUtils.isDefaultRoom(report); - result.isArchivedRoom = ReportUtils.isArchivedRoom(report, reportNameValuePairs); + // eslint-disable-next-line @typescript-eslint/naming-convention + result.private_isArchived = report.private_isArchived; result.isExpenseReport = ReportUtils.isExpenseReport(report); result.isInvoiceRoom = ReportUtils.isInvoiceRoom(report); result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); @@ -1588,7 +1586,7 @@ function orderOptions(options: ReportUtils.OptionData[], searchValue: string | u if (preferChatroomsOverThreads && option.isThread) { return 4; } - if (!!option.isChatRoom || option.isArchivedRoom) { + if (!!option.isChatRoom || option.private_isArchived) { return 3; } if (!option.login) { @@ -1833,7 +1831,7 @@ function getOptions( // - All archived reports should remain at the bottom const orderedReportOptions = lodashSortBy(filteredReportOptions, (option) => { const report = option.item; - if (option.isArchivedRoom) { + if (option.private_isArchived) { return CONST.DATE.UNIX_EPOCH; } @@ -1942,10 +1940,10 @@ function getOptions( } const isCurrentUserOwnedPolicyExpenseChatThatCouldShow = - reportOption.isPolicyExpenseChat && reportOption.ownerAccountID === currentUserAccountID && includeOwnedWorkspaceChats && !reportOption.isArchivedRoom; + reportOption.isPolicyExpenseChat && reportOption.ownerAccountID === currentUserAccountID && includeOwnedWorkspaceChats && !reportOption.private_isArchived; const shouldShowInvoiceRoom = - includeInvoiceRooms && ReportUtils.isInvoiceRoom(reportOption.item) && ReportUtils.isPolicyAdmin(reportOption.policyID ?? '', policies) && !reportOption.isArchivedRoom; + includeInvoiceRooms && ReportUtils.isInvoiceRoom(reportOption.item) && ReportUtils.isPolicyAdmin(reportOption.policyID ?? '', policies) && !reportOption.private_isArchived; // TODO: Uncomment the following line when the invoices screen is ready - https://github.com/Expensify/App/issues/45175. // && PolicyUtils.canSendInvoiceFromWorkspace(reportOption.policyID); @@ -2305,7 +2303,7 @@ function getHeaderMessageForNonUserList(hasSelectableOptions: boolean, searchVal * Helper method to check whether an option can show tooltip or not */ function shouldOptionShowTooltip(option: ReportUtils.OptionData): boolean { - return (!option.isChatRoom || !!option.isThread) && !option.isArchivedRoom; + return (!option.isChatRoom || !!option.isThread) && !option.private_isArchived; } /** diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a92c89479c74..f37f3f940516 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -426,7 +426,6 @@ type OptionData = { keyForList?: string; searchText?: string; isIOUReportOwner?: boolean | null; - isArchivedRoom?: boolean | null; shouldShowSubscript?: boolean | null; isPolicyExpenseChat?: boolean | null; isMoneyRequestReport?: boolean | null; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 0908892dc376..d056f111695e 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -284,7 +284,8 @@ function getOptionData({ hasParentAccess: undefined, isIOUReportOwner: null, isChatRoom: false, - isArchivedRoom: false, + // eslint-disable-next-line @typescript-eslint/naming-convention + private_isArchived: undefined, shouldShowSubscript: false, isPolicyExpenseChat: false, isMoneyRequestReport: false, @@ -307,8 +308,8 @@ function getOptionData({ result.isTaskReport = ReportUtils.isTaskReport(report); result.isInvoiceReport = ReportUtils.isInvoiceReport(report); result.parentReportAction = parentReportAction; - const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); - result.isArchivedRoom = ReportUtils.isArchivedRoom(report, reportNameValuePairs); + // eslint-disable-next-line @typescript-eslint/naming-convention + result.private_isArchived = report?.private_isArchived; result.isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); result.isExpenseRequest = ReportUtils.isExpenseRequest(report); result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); @@ -399,8 +400,7 @@ function getOptionData({ const isThreadMessage = ReportUtils.isThread(report) && lastAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ADD_COMMENT && lastAction?.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; - - if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage) && !result.isArchivedRoom) { + if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage) && !result.private_isArchived) { const lastActionName = lastAction?.actionName ?? report.lastActionType; if (ReportActionsUtils.isRenamedAction(lastAction)) { @@ -577,8 +577,7 @@ function getRoomWelcomeMessage(report: OnyxEntry): WelcomeMessage { return welcomeMessage; } - const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); - if (ReportUtils.isArchivedRoom(report, reportNameValuePairs)) { + if (report?.private_isArchived) { welcomeMessage.phrase1 = Localize.translateLocal('reportActionsView.beginningOfArchivedRoomPartOne'); welcomeMessage.phrase2 = Localize.translateLocal('reportActionsView.beginningOfArchivedRoomPartTwo'); } else if (ReportUtils.isDomainRoom(report)) { diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts index 6247dbba1f50..d27a53da69ce 100644 --- a/tests/unit/OptionsListUtilsTest.ts +++ b/tests/unit/OptionsListUtilsTest.ts @@ -2641,7 +2641,7 @@ describe('OptionsListUtils', () => { const filteredOptions = OptionsListUtils.filterOptions(options, searchText); expect(filteredOptions.recentReports.length).toBe(1); - expect(filteredOptions.recentReports[0].isArchivedRoom).toBe(true); + expect(!!filteredOptions.recentReports[0].private_isArchived).toBe(true); }); it('should filter options by email if dot is skipped in the email', () => { diff --git a/tests/utils/collections/optionData.ts b/tests/utils/collections/optionData.ts index 9b9c62381d0f..a589daf8a913 100644 --- a/tests/utils/collections/optionData.ts +++ b/tests/utils/collections/optionData.ts @@ -19,7 +19,8 @@ export default function createRandomOptionData(index: number): OptionData { policyName: randWord(), policyID: `policy_${index}`, accountID: randNumber(), - isArchivedRoom: randBoolean(), + // eslint-disable-next-line @typescript-eslint/naming-convention + private_isArchived: new Date().toISOString(), isPolicyExpenseChat: randBoolean(), chatType: rand(Object.values(CONST.REPORT.CHAT_TYPE)), hasOutstandingChildRequest: randBoolean(),