From 4d3087bb7117dd46d304065ff99b2f9514a55d4e Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Wed, 7 Aug 2024 08:05:33 +0700 Subject: [PATCH 01/20] update archive feature --- src/libs/SidebarUtils.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index eae047d3eb7f..5abc9f355e2a 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -283,7 +283,7 @@ function getOptionData({ hasParentAccess: undefined, isIOUReportOwner: null, isChatRoom: false, - isArchivedRoom: false, + private_isArchived: undefined, shouldShowSubscript: false, isPolicyExpenseChat: false, isMoneyRequestReport: false, @@ -306,8 +306,7 @@ 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); + result.private_isArchived = report.private_isArchived; result.isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); result.isExpenseRequest = ReportUtils.isExpenseRequest(report); result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); @@ -395,8 +394,8 @@ 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) { + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); + if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage) && !ReportUtils.isArchivedRoom(report, reportNameValuePairs)) { const lastActionName = lastAction?.actionName ?? report.lastActionType; if (ReportActionsUtils.isRenamedAction(lastAction)) { From 8eccb7b8d2eb29c4321aff594dc7d7fd26a57f99 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Wed, 7 Aug 2024 08:23:12 +0700 Subject: [PATCH 02/20] address lint error --- src/libs/SidebarUtils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 5abc9f355e2a..c12baaa3c5d3 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -283,6 +283,7 @@ function getOptionData({ hasParentAccess: undefined, isIOUReportOwner: null, isChatRoom: false, + // eslint-disable-next-line @typescript-eslint/naming-convention private_isArchived: undefined, shouldShowSubscript: false, isPolicyExpenseChat: false, @@ -306,6 +307,7 @@ function getOptionData({ result.isTaskReport = ReportUtils.isTaskReport(report); result.isInvoiceReport = ReportUtils.isInvoiceReport(report); result.parentReportAction = parentReportAction; + // eslint-disable-next-line @typescript-eslint/naming-convention result.private_isArchived = report.private_isArchived; result.isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); result.isExpenseRequest = ReportUtils.isExpenseRequest(report); From cc7564ef969920814f8c5bdeb7d011ce462e9ded Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Tue, 13 Aug 2024 16:30:34 +0700 Subject: [PATCH 03/20] apply the new update --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index b9be3ffac761..98dcf123f53e 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -2332,7 +2332,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) && !ReportUtils.isArchivedRoom(option, ReportUtils.getReportNameValuePairs(option?.reportID)); } /** From bde5ae281ca1667223eb468200d9dea800be4725 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 22 Aug 2024 14:50:13 +0700 Subject: [PATCH 04/20] add type --- src/libs/ReportUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index cda35311122a..847f663ea2b5 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -428,6 +428,7 @@ type OptionData = { hasDraftComment?: boolean | null; keyForList?: string; searchText?: string; + private_isArchived?: string | null; isIOUReportOwner?: boolean | null; isArchivedRoom?: boolean | null; shouldShowSubscript?: boolean | null; From c3571611ca23c9a660f924307f38da141074903f Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 22 Aug 2024 14:52:31 +0700 Subject: [PATCH 05/20] disable naming convention --- src/libs/ReportUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 847f663ea2b5..57d5c455faf1 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -428,6 +428,7 @@ type OptionData = { hasDraftComment?: boolean | null; keyForList?: string; searchText?: string; + // eslint-disable-next-line @typescript-eslint/naming-convention private_isArchived?: string | null; isIOUReportOwner?: boolean | null; isArchivedRoom?: boolean | null; From 9d9ee77fc301d80f784e6d0affd635483095cb6c Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Fri, 6 Sep 2024 18:36:02 +0700 Subject: [PATCH 06/20] remopve dupe --- src/libs/ReportUtils.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 57d5c455faf1..cda35311122a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -428,8 +428,6 @@ type OptionData = { hasDraftComment?: boolean | null; keyForList?: string; searchText?: string; - // eslint-disable-next-line @typescript-eslint/naming-convention - private_isArchived?: string | null; isIOUReportOwner?: boolean | null; isArchivedRoom?: boolean | null; shouldShowSubscript?: boolean | null; From 8c660d1be886a1dc6c942ee7fc0d35bab4e049aa Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 12 Sep 2024 23:32:09 +0700 Subject: [PATCH 07/20] add extra fix --- src/libs/OptionsListUtils.ts | 17 ++++++++++------- src/libs/ReportUtils.ts | 1 - 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index e768a4ab254a..11440d4283e7 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -712,7 +712,6 @@ function createOption( isIOUReportOwner: null, iouReportAmount: 0, isChatRoom: false, - isArchivedRoom: false, shouldShowSubscript: false, isPolicyExpenseChat: false, isOwnPolicyExpenseChat: false, @@ -730,11 +729,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 +1587,8 @@ function orderOptions(options: ReportUtils.OptionData[], searchValue: string | u if (preferChatroomsOverThreads && option.isThread) { return 4; } - if (!!option.isChatRoom || option.isArchivedRoom) { + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(option?.reportID); + if (!!option.isChatRoom || ReportUtils.isArchivedRoom(option, reportNameValuePairs)) { return 3; } if (!option.login) { @@ -1833,7 +1833,8 @@ function getOptions( // - All archived reports should remain at the bottom const orderedReportOptions = lodashSortBy(filteredReportOptions, (option) => { const report = option.item; - if (option.isArchivedRoom) { + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(option?.reportID); + if (ReportUtils.isArchivedRoom(option, reportNameValuePairs)) { return CONST.DATE.UNIX_EPOCH; } @@ -1941,11 +1942,13 @@ function getOptions( continue; } + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(reportOption?.reportID); + const isArchivedRoom = ReportUtils.isArchivedRoom(reportOption, reportNameValuePairs); const isCurrentUserOwnedPolicyExpenseChatThatCouldShow = - reportOption.isPolicyExpenseChat && reportOption.ownerAccountID === currentUserAccountID && includeOwnedWorkspaceChats && !reportOption.isArchivedRoom; + reportOption.isPolicyExpenseChat && reportOption.ownerAccountID === currentUserAccountID && includeOwnedWorkspaceChats && !isArchivedRoom; const shouldShowInvoiceRoom = - includeInvoiceRooms && ReportUtils.isInvoiceRoom(reportOption.item) && ReportUtils.isPolicyAdmin(reportOption.policyID ?? '', policies) && !reportOption.isArchivedRoom; + includeInvoiceRooms && ReportUtils.isInvoiceRoom(reportOption.item) && ReportUtils.isPolicyAdmin(reportOption.policyID ?? '', policies) && !isArchivedRoom; // TODO: Uncomment the following line when the invoices screen is ready - https://github.com/Expensify/App/issues/45175. // && PolicyUtils.canSendInvoiceFromWorkspace(reportOption.policyID); diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 0e7418a306af..ddb61677e2d0 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -425,7 +425,6 @@ type OptionData = { keyForList?: string; searchText?: string; isIOUReportOwner?: boolean | null; - isArchivedRoom?: boolean | null; shouldShowSubscript?: boolean | null; isPolicyExpenseChat?: boolean | null; isMoneyRequestReport?: boolean | null; From 1fef9dffb962463b41ad2996d21bde49abee60fb Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Thu, 12 Sep 2024 23:57:16 +0700 Subject: [PATCH 08/20] fix test --- tests/unit/OptionsListUtilsTest.ts | 4 +++- tests/utils/collections/optionData.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts index 6247dbba1f50..40dbf1ed6e0a 100644 --- a/tests/unit/OptionsListUtilsTest.ts +++ b/tests/unit/OptionsListUtilsTest.ts @@ -2639,9 +2639,11 @@ describe('OptionsListUtils', () => { const searchText = 'Archived'; const options = OptionsListUtils.getSearchOptions(OPTIONS, '', [CONST.BETAS.ALL]); const filteredOptions = OptionsListUtils.filterOptions(options, searchText); + const reportNameValuePairs = ReportUtils.getReportNameValuePairs(filteredOptions.recentReports[0]?.reportID); + const isArchivedRoom = ReportUtils.isArchivedRoom(filteredOptions.recentReports[0], reportNameValuePairs); expect(filteredOptions.recentReports.length).toBe(1); - expect(filteredOptions.recentReports[0].isArchivedRoom).toBe(true); + expect(isArchivedRoom).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..c32e7ef34df3 100644 --- a/tests/utils/collections/optionData.ts +++ b/tests/utils/collections/optionData.ts @@ -19,7 +19,7 @@ export default function createRandomOptionData(index: number): OptionData { policyName: randWord(), policyID: `policy_${index}`, accountID: randNumber(), - isArchivedRoom: randBoolean(), + private_isArchived: new Date().toISOString(), isPolicyExpenseChat: randBoolean(), chatType: rand(Object.values(CONST.REPORT.CHAT_TYPE)), hasOutstandingChildRequest: randBoolean(), From b5a0fcd643eeac2cf0048f6b4c97ec599ae0e9ec Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Fri, 13 Sep 2024 00:13:39 +0700 Subject: [PATCH 09/20] fix test --- tests/utils/collections/optionData.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/utils/collections/optionData.ts b/tests/utils/collections/optionData.ts index c32e7ef34df3..a589daf8a913 100644 --- a/tests/utils/collections/optionData.ts +++ b/tests/utils/collections/optionData.ts @@ -19,6 +19,7 @@ export default function createRandomOptionData(index: number): OptionData { policyName: randWord(), policyID: `policy_${index}`, accountID: randNumber(), + // eslint-disable-next-line @typescript-eslint/naming-convention private_isArchived: new Date().toISOString(), isPolicyExpenseChat: randBoolean(), chatType: rand(Object.values(CONST.REPORT.CHAT_TYPE)), From eb1cccfd3e00648837b56fc51284a9daa65582d0 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Fri, 13 Sep 2024 21:46:56 +0700 Subject: [PATCH 10/20] using private_isArchived directly --- src/libs/OptionsListUtils.ts | 17 ++++++----------- src/libs/SidebarUtils.ts | 3 +-- tests/unit/OptionsListUtilsTest.ts | 4 +--- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 11440d4283e7..a429f07dbe5f 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; @@ -1587,8 +1586,7 @@ function orderOptions(options: ReportUtils.OptionData[], searchValue: string | u if (preferChatroomsOverThreads && option.isThread) { return 4; } - const reportNameValuePairs = ReportUtils.getReportNameValuePairs(option?.reportID); - if (!!option.isChatRoom || ReportUtils.isArchivedRoom(option, reportNameValuePairs)) { + if (!!option.isChatRoom || option?.private_isArchived) { return 3; } if (!option.login) { @@ -1833,8 +1831,7 @@ function getOptions( // - All archived reports should remain at the bottom const orderedReportOptions = lodashSortBy(filteredReportOptions, (option) => { const report = option.item; - const reportNameValuePairs = ReportUtils.getReportNameValuePairs(option?.reportID); - if (ReportUtils.isArchivedRoom(option, reportNameValuePairs)) { + if (option?.private_isArchived) { return CONST.DATE.UNIX_EPOCH; } @@ -1942,13 +1939,11 @@ function getOptions( continue; } - const reportNameValuePairs = ReportUtils.getReportNameValuePairs(reportOption?.reportID); - const isArchivedRoom = ReportUtils.isArchivedRoom(reportOption, reportNameValuePairs); const isCurrentUserOwnedPolicyExpenseChatThatCouldShow = - reportOption.isPolicyExpenseChat && reportOption.ownerAccountID === currentUserAccountID && includeOwnedWorkspaceChats && !isArchivedRoom; + reportOption.isPolicyExpenseChat && reportOption.ownerAccountID === currentUserAccountID && includeOwnedWorkspaceChats && !reportOption?.private_isArchived; const shouldShowInvoiceRoom = - includeInvoiceRooms && ReportUtils.isInvoiceRoom(reportOption.item) && ReportUtils.isPolicyAdmin(reportOption.policyID ?? '', policies) && !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); @@ -2308,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) && !ReportUtils.isArchivedRoom(option, ReportUtils.getReportNameValuePairs(option?.reportID)); + return (!option.isChatRoom || !!option.isThread) && !option?.private_isArchived; } /** diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 5166d0b99540..f220455ef99f 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -400,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; - const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); - if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage) && !ReportUtils.isArchivedRoom(report, reportNameValuePairs)) { + if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage) && !report?.private_isArchived) { const lastActionName = lastAction?.actionName ?? report.lastActionType; if (ReportActionsUtils.isRenamedAction(lastAction)) { diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts index 40dbf1ed6e0a..1f81a0d98042 100644 --- a/tests/unit/OptionsListUtilsTest.ts +++ b/tests/unit/OptionsListUtilsTest.ts @@ -2639,11 +2639,9 @@ describe('OptionsListUtils', () => { const searchText = 'Archived'; const options = OptionsListUtils.getSearchOptions(OPTIONS, '', [CONST.BETAS.ALL]); const filteredOptions = OptionsListUtils.filterOptions(options, searchText); - const reportNameValuePairs = ReportUtils.getReportNameValuePairs(filteredOptions.recentReports[0]?.reportID); - const isArchivedRoom = ReportUtils.isArchivedRoom(filteredOptions.recentReports[0], reportNameValuePairs); expect(filteredOptions.recentReports.length).toBe(1); - expect(isArchivedRoom).toBe(true); + expect(filteredOptions.recentReports[0].private_isArchived).toBe(true); }); it('should filter options by email if dot is skipped in the email', () => { From 6ef653a8231fea5150e818eabd35b05376aeb6b6 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Fri, 13 Sep 2024 22:07:36 +0700 Subject: [PATCH 11/20] update --- src/libs/SidebarUtils.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index f220455ef99f..0e2d811049a5 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -400,7 +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) && !report?.private_isArchived) { + if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage) && !result?.private_isArchived) { const lastActionName = lastAction?.actionName ?? report.lastActionType; if (ReportActionsUtils.isRenamedAction(lastAction)) { @@ -575,8 +575,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)) { From 468635072266046aef6a094f78226ea2b1bed083 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Fri, 13 Sep 2024 22:09:59 +0700 Subject: [PATCH 12/20] update --- src/libs/OptionsListUtils.ts | 4 ++-- src/libs/SidebarUtils.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index a429f07dbe5f..99c6cee1b0f5 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -596,7 +596,7 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails const lastOriginalReportAction = lastReportActions[reportID] ?? null; let lastMessageTextFromReport = ''; - if (!report?.private_isArchived) { + 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; @@ -732,7 +732,7 @@ function createOption( result.isChatRoom = ReportUtils.isChatRoom(report); result.isDefaultRoom = ReportUtils.isDefaultRoom(report); // eslint-disable-next-line @typescript-eslint/naming-convention - result.private_isArchived = report.private_isArchived; + result.private_isArchived = report?.private_isArchived; result.isExpenseReport = ReportUtils.isExpenseReport(report); result.isInvoiceRoom = ReportUtils.isInvoiceRoom(report); result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 0e2d811049a5..beffd2cc6e20 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -309,7 +309,7 @@ function getOptionData({ result.isInvoiceReport = ReportUtils.isInvoiceReport(report); result.parentReportAction = parentReportAction; // eslint-disable-next-line @typescript-eslint/naming-convention - result.private_isArchived = report.private_isArchived; + result.private_isArchived = report?.private_isArchived; result.isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); result.isExpenseRequest = ReportUtils.isExpenseRequest(report); result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); From 5b741a5fe5ca70bb164a1686f67f77e80f203fc6 Mon Sep 17 00:00:00 2001 From: cretadn22 Date: Fri, 13 Sep 2024 22:36:31 +0700 Subject: [PATCH 13/20] fix test --- tests/unit/OptionsListUtilsTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/OptionsListUtilsTest.ts b/tests/unit/OptionsListUtilsTest.ts index 1f81a0d98042..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].private_isArchived).toBe(true); + expect(!!filteredOptions.recentReports[0].private_isArchived).toBe(true); }); it('should filter options by email if dot is skipped in the email', () => { From 8ebc86d572579089986b0545ed476413bbba3946 Mon Sep 17 00:00:00 2001 From: cretadn22 <168617111+cretadn22@users.noreply.github.com> Date: Tue, 17 Sep 2024 08:32:00 +0700 Subject: [PATCH 14/20] Update src/libs/OptionsListUtils.ts Co-authored-by: Situ Chandra Shil <108292595+situchan@users.noreply.github.com> --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 99c6cee1b0f5..90aec01f80e0 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -732,7 +732,7 @@ function createOption( result.isChatRoom = ReportUtils.isChatRoom(report); result.isDefaultRoom = ReportUtils.isDefaultRoom(report); // eslint-disable-next-line @typescript-eslint/naming-convention - result.private_isArchived = report?.private_isArchived; + result.private_isArchived = report.private_isArchived; result.isExpenseReport = ReportUtils.isExpenseReport(report); result.isInvoiceRoom = ReportUtils.isInvoiceRoom(report); result.isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); From e7aadc22348a1b5e51ec7eeb29667792f590151f Mon Sep 17 00:00:00 2001 From: cretadn22 <168617111+cretadn22@users.noreply.github.com> Date: Tue, 17 Sep 2024 08:32:09 +0700 Subject: [PATCH 15/20] Update src/libs/SidebarUtils.ts Co-authored-by: Situ Chandra Shil <108292595+situchan@users.noreply.github.com> --- src/libs/SidebarUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index beffd2cc6e20..8324a214d590 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -400,7 +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?.private_isArchived) { + if ((result.isChatRoom || result.isPolicyExpenseChat || result.isThread || result.isTaskReport || isThreadMessage) && !result.private_isArchived) { const lastActionName = lastAction?.actionName ?? report.lastActionType; if (ReportActionsUtils.isRenamedAction(lastAction)) { From 85593adebf8766001470bdede62446b7292c1bcb Mon Sep 17 00:00:00 2001 From: cretadn22 <168617111+cretadn22@users.noreply.github.com> Date: Tue, 17 Sep 2024 08:32:19 +0700 Subject: [PATCH 16/20] Update src/libs/OptionsListUtils.ts Co-authored-by: Situ Chandra Shil <108292595+situchan@users.noreply.github.com> --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 90aec01f80e0..b728de23a5b1 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1943,7 +1943,7 @@ function getOptions( reportOption.isPolicyExpenseChat && reportOption.ownerAccountID === currentUserAccountID && includeOwnedWorkspaceChats && !reportOption?.private_isArchived; const shouldShowInvoiceRoom = - includeInvoiceRooms && ReportUtils.isInvoiceRoom(reportOption.item) && ReportUtils.isPolicyAdmin(reportOption.policyID ?? '', policies) && !reportOption?.private_isArchived; + 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); From efbad6f8311532c7ec6a2881052473416435162a Mon Sep 17 00:00:00 2001 From: cretadn22 <168617111+cretadn22@users.noreply.github.com> Date: Tue, 17 Sep 2024 08:32:30 +0700 Subject: [PATCH 17/20] Update src/libs/OptionsListUtils.ts Co-authored-by: Situ Chandra Shil <108292595+situchan@users.noreply.github.com> --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index b728de23a5b1..ed4d7ba0a177 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -2303,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?.private_isArchived; + return (!option.isChatRoom || !!option.isThread) && !option.private_isArchived; } /** From 18ab3c16bac9903d7e16973d4bc3962052e51f99 Mon Sep 17 00:00:00 2001 From: cretadn22 <168617111+cretadn22@users.noreply.github.com> Date: Tue, 17 Sep 2024 08:32:39 +0700 Subject: [PATCH 18/20] Update src/libs/OptionsListUtils.ts Co-authored-by: Situ Chandra Shil <108292595+situchan@users.noreply.github.com> --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index ed4d7ba0a177..ce104ba730ac 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1940,7 +1940,7 @@ function getOptions( } const isCurrentUserOwnedPolicyExpenseChatThatCouldShow = - reportOption.isPolicyExpenseChat && reportOption.ownerAccountID === currentUserAccountID && includeOwnedWorkspaceChats && !reportOption?.private_isArchived; + reportOption.isPolicyExpenseChat && reportOption.ownerAccountID === currentUserAccountID && includeOwnedWorkspaceChats && !reportOption.private_isArchived; const shouldShowInvoiceRoom = includeInvoiceRooms && ReportUtils.isInvoiceRoom(reportOption.item) && ReportUtils.isPolicyAdmin(reportOption.policyID ?? '', policies) && !reportOption.private_isArchived; From ae281b6baa8fe106cbaf599d4eb887f117316860 Mon Sep 17 00:00:00 2001 From: cretadn22 <168617111+cretadn22@users.noreply.github.com> Date: Tue, 17 Sep 2024 08:32:46 +0700 Subject: [PATCH 19/20] Update src/libs/OptionsListUtils.ts Co-authored-by: Situ Chandra Shil <108292595+situchan@users.noreply.github.com> --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index ce104ba730ac..1be283b909de 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1586,7 +1586,7 @@ function orderOptions(options: ReportUtils.OptionData[], searchValue: string | u if (preferChatroomsOverThreads && option.isThread) { return 4; } - if (!!option.isChatRoom || option?.private_isArchived) { + if (!!option.isChatRoom || option.private_isArchived) { return 3; } if (!option.login) { From 96c5cd20d1cd934c4003ca5fdfe506e0d14dd408 Mon Sep 17 00:00:00 2001 From: cretadn22 <168617111+cretadn22@users.noreply.github.com> Date: Tue, 17 Sep 2024 08:32:54 +0700 Subject: [PATCH 20/20] Update src/libs/OptionsListUtils.ts Co-authored-by: Situ Chandra Shil <108292595+situchan@users.noreply.github.com> --- src/libs/OptionsListUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 1be283b909de..afedd308371c 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -1831,7 +1831,7 @@ function getOptions( // - All archived reports should remain at the bottom const orderedReportOptions = lodashSortBy(filteredReportOptions, (option) => { const report = option.item; - if (option?.private_isArchived) { + if (option.private_isArchived) { return CONST.DATE.UNIX_EPOCH; }