From 4f1e03608831d1266d9217847bf01b7638848130 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 7 Nov 2024 16:20:46 +0300 Subject: [PATCH 01/29] separated isArchivedExpenseReport --- src/libs/ReportUtils.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a62716975c01..230297b8c5e4 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1447,7 +1447,14 @@ function isClosedExpenseReportWithNoExpenses(report: OnyxEntry): boolean */ // eslint-disable-next-line @typescript-eslint/no-unused-vars function isArchivedRoom(report: OnyxInputOrEntry, reportNameValuePairs?: OnyxInputOrEntry): boolean { - return !!report?.private_isArchived; + return !isExpenseReport(report) && !!report?.private_isArchived; +} + +/** + * Whether the provided report is an archived expense report + */ +function isArchivedExpenseReport(report: OnyxInputOrEntry): boolean { + return isExpenseReport(report) && !!report?.private_isArchived; } /** @@ -6998,7 +7005,7 @@ function isGroupChatAdmin(report: OnyxEntry, accountID: number) { */ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry, reportParticipants: number[], filterDeprecatedTypes = false): IOUType[] { // In any thread or task report, we do not allow any new expenses yet - if (isChatThread(report) || isTaskReport(report) || isInvoiceReport(report) || isSystemChat(report)) { + if (isChatThread(report) || isTaskReport(report) || isInvoiceReport(report) || isSystemChat(report) || isArchivedExpenseReport(report)) { return []; } @@ -8587,6 +8594,7 @@ export { isAllowedToSubmitDraftExpenseReport, isAnnounceRoom, isArchivedRoom, + isArchivedExpenseReport, isArchivedRoomWithID, isClosedReport, isCanceledTaskReport, From e479b039540c475cdd9dcb94dd39158337abe925 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 7 Nov 2024 16:31:35 +0300 Subject: [PATCH 02/29] hide approve and submit button for archived expense reports --- src/components/MoneyReportHeader.tsx | 3 +++ src/components/ReportActionItem/ReportPreview.tsx | 5 ++++- src/libs/actions/IOU.ts | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 3caf7a15d50e..993596ed5203 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -118,6 +118,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const hasOnlyHeldExpenses = ReportUtils.hasOnlyHeldExpenses(moneyRequestReport?.reportID ?? ''); const isPayAtEndExpense = TransactionUtils.isPayAtEndExpense(transaction); const isArchivedReport = ReportUtils.isArchivedRoomWithID(moneyRequestReport?.reportID); + const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(moneyRequestReport); const [archiveReason] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport?.reportID ?? '-1'}`, {selector: ReportUtils.getArchiveReason}); const getCanIOUBePaid = useCallback( @@ -143,6 +144,8 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const shouldShowSubmitButton = !!moneyRequestReport && + !isArchivedReport && + !isArchivedExpenseReport && isDraft && reimbursableSpend !== 0 && !hasAllPendingRTERViolations && diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index 9067f1abb11a..4ec390b79d6d 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -174,10 +174,14 @@ function ReportPreview({ formattedMerchant = null; } + const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(iouReport); + const isArchivedReport = ReportUtils.isArchivedRoomWithID(iouReportID); const currentUserAccountID = getCurrentUserAccountID(); const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; const shouldShowSubmitButton = isOpenExpenseReport && + !isArchivedExpenseReport && + !isArchivedReport && reimbursableSpend !== 0 && !showRTERViolationMessage && !shouldShowBrokenConnectionViolation && @@ -358,7 +362,6 @@ function ReportPreview({ const shouldShowPendingSubtitle = numberOfPendingRequests === 1 && numberOfRequests === 1; const isPayAtEndExpense = ReportUtils.isPayAtEndExpenseReport(iouReportID, allTransactions); - const isArchivedReport = ReportUtils.isArchivedRoomWithID(iouReportID); const [archiveReason] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, {selector: ReportUtils.getArchiveReason}); const getPendingMessageProps: () => PendingMessageProps = () => { diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 3d0324d81549..cd9068a79d82 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -7055,6 +7055,8 @@ function canApproveIOU(iouReport: OnyxTypes.OnyxInputOrEntry, const iouSettled = ReportUtils.isSettled(iouReport?.reportID); const reportNameValuePairs = ReportUtils.getReportNameValuePairs(iouReport?.reportID); const isArchivedReport = ReportUtils.isArchivedRoom(iouReport, reportNameValuePairs); + const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(iouReport); + let isTransactionBeingScanned = false; const reportTransactions = TransactionUtils.getAllReportTransactions(iouReport?.reportID); for (const transaction of reportTransactions) { @@ -7067,7 +7069,7 @@ function canApproveIOU(iouReport: OnyxTypes.OnyxInputOrEntry, } } - return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport && !isTransactionBeingScanned; + return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport && !isArchivedExpenseReport && !isTransactionBeingScanned; } function canIOUBePaid( From 80079f1ec3499028c91ca94490f87df99c2a73c0 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 11 Nov 2024 13:50:32 +0300 Subject: [PATCH 03/29] removed isArchived conditions --- src/components/MoneyReportHeader.tsx | 1 - src/libs/actions/IOU.ts | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 993596ed5203..359c6d9e46db 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -144,7 +144,6 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const shouldShowSubmitButton = !!moneyRequestReport && - !isArchivedReport && !isArchivedExpenseReport && isDraft && reimbursableSpend !== 0 && diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index cd9068a79d82..2e3587c08180 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -7053,8 +7053,6 @@ function canApproveIOU(iouReport: OnyxTypes.OnyxInputOrEntry, const isOpenExpenseReport = ReportUtils.isOpenExpenseReport(iouReport); const isApproved = ReportUtils.isReportApproved(iouReport); const iouSettled = ReportUtils.isSettled(iouReport?.reportID); - const reportNameValuePairs = ReportUtils.getReportNameValuePairs(iouReport?.reportID); - const isArchivedReport = ReportUtils.isArchivedRoom(iouReport, reportNameValuePairs); const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(iouReport); let isTransactionBeingScanned = false; @@ -7069,7 +7067,7 @@ function canApproveIOU(iouReport: OnyxTypes.OnyxInputOrEntry, } } - return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport && !isArchivedExpenseReport && !isTransactionBeingScanned; + return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedExpenseReport && !isTransactionBeingScanned; } function canIOUBePaid( From 6e97db28f5d9488530f27b0f3b2d77630ebc04ed Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 13 Nov 2024 15:26:41 +0300 Subject: [PATCH 04/29] removed unnecessary code --- src/libs/actions/IOU.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 567148e9cbfe..7bc44c567b75 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6755,8 +6755,6 @@ function canApproveIOU(iouReport: OnyxTypes.OnyxInputOrEntry, const isApproved = ReportUtils.isReportApproved(iouReport); const iouSettled = ReportUtils.isSettled(iouReport?.reportID); const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(iouReport); - const reportNameValuePairs = ReportUtils.getReportNameValuePairs(iouReport?.reportID); - const isArchivedReport = ReportUtils.isArchivedRoom(iouReport, reportNameValuePairs); let isTransactionBeingScanned = false; const reportTransactions = TransactionUtils.getAllReportTransactions(iouReport?.reportID); for (const transaction of reportTransactions) { From 58258ed4d00588888c00296778bd919dc6d3a4a1 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 13 Nov 2024 15:31:19 +0300 Subject: [PATCH 05/29] remove unnecessary condition --- src/components/ReportActionItem/ReportPreview.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index faf487ed8dae..9485017eb701 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -182,7 +182,6 @@ function ReportPreview({ const shouldShowSubmitButton = isOpenExpenseReport && !isArchivedExpenseReport && - !isArchivedReport && reimbursableSpend !== 0 && !showRTERViolationMessage && !shouldShowBrokenConnectionViolation && From a79e87b79472cc1c1a941136231277057446fab1 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 21 Nov 2024 23:59:08 +0300 Subject: [PATCH 06/29] updated isArchived conditions --- .../BaseAnchorForAttachmentsOnly.tsx | 9 ++- .../HTMLRenderers/ImageRenderer.tsx | 9 ++- .../HTMLRenderers/MentionUserRenderer.tsx | 9 ++- .../HTMLRenderers/PreRenderer.tsx | 9 ++- src/components/ReportWelcomeText.tsx | 2 +- .../VideoPlayerThumbnail.tsx | 9 ++- src/libs/ReportUtils.ts | 73 +++++++++++-------- src/libs/SidebarUtils.ts | 2 +- src/libs/actions/IOU.ts | 2 +- src/libs/actions/Task.ts | 2 +- src/pages/ReportDetailsPage.tsx | 13 +++- src/pages/ReportParticipantsPage.tsx | 2 +- src/pages/home/HeaderView.tsx | 2 +- .../BaseReportActionContextMenu.tsx | 2 +- src/pages/home/report/ReportActionItem.tsx | 2 +- src/pages/home/report/ReportActionsList.tsx | 4 +- src/pages/home/report/ReportFooter.tsx | 2 +- .../withReportAndPrivateNotesOrNotFound.tsx | 2 +- .../FloatingActionButtonAndPopover.tsx | 2 +- .../iou/request/step/IOURequestStepAmount.tsx | 4 +- .../request/step/IOURequestStepDistance.tsx | 4 +- .../step/IOURequestStepScan/index.native.tsx | 3 +- .../request/step/IOURequestStepScan/index.tsx | 3 +- .../Report/NotificationPreferencePage.tsx | 2 +- .../settings/Report/ReportSettingsPage.tsx | 2 +- src/pages/settings/Report/VisibilityPage.tsx | 2 +- .../accounting/PolicyAccountingPage.tsx | 1 + 27 files changed, 118 insertions(+), 60 deletions(-) diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index ae74a11c7e9d..dc3841e2e8ee 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -51,7 +51,14 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP if (isDisabled) { return; } - showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs)); + showContextMenuForReport( + event, + anchor, + report?.reportID ?? '-1', + action, + checkIfContextMenuActive, + ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs), + ); }} shouldUseHapticsOnLongPress accessibilityLabel={displayName} diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx index c27eef1de91e..5587bbed1094 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx @@ -112,7 +112,14 @@ function ImageRenderer({tnode}: ImageRendererProps) { if (isDisabled) { return; } - showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs)); + showContextMenuForReport( + event, + anchor, + report?.reportID ?? '-1', + action, + checkIfContextMenuActive, + ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs), + ); }} shouldUseHapticsOnLongPress accessibilityRole={CONST.ROLE.BUTTON} diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx index 36586b09e514..21c6a3e87aec 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx @@ -90,7 +90,14 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona if (isDisabled) { return; } - showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs)); + showContextMenuForReport( + event, + anchor, + report?.reportID ?? '-1', + action, + checkIfContextMenuActive, + ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs), + ); }} onPress={(event) => { event.preventDefault(); diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx index b1e5c21500f0..8b1920b66ba0 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx @@ -43,7 +43,14 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d if (isDisabled) { return; } - showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs)); + showContextMenuForReport( + event, + anchor, + report?.reportID ?? '-1', + action, + checkIfContextMenuActive, + ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs), + ); }} shouldUseHapticsOnLongPress role={CONST.ROLE.PRESENTATION} diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 3c38c9f4c4a3..f7c47406084d 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -34,7 +34,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) { const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || -1}`); - const isArchivedRoom = ReportUtils.isArchivedRoom(report, reportNameValuePairs); + const isArchivedRoom = ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs); const isChatRoom = ReportUtils.isChatRoom(report); const isSelfDM = ReportUtils.isSelfDM(report); const isInvoiceRoom = ReportUtils.isInvoiceRoom(report); diff --git a/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx b/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx index 832b5eef45f0..edf6693c172e 100644 --- a/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx +++ b/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx @@ -57,7 +57,14 @@ function VideoPlayerThumbnail({thumbnailUrl, onPress, accessibilityLabel, isDele if (isDisabled) { return; } - showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs)); + showContextMenuForReport( + event, + anchor, + report?.reportID ?? '-1', + action, + checkIfContextMenuActive, + ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs), + ); }} shouldUseHapticsOnLongPress > diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 5b51f9575297..6833b875dd1b 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1461,7 +1461,7 @@ function isClosedExpenseReportWithNoExpenses(report: OnyxEntry): boolean * Whether the provided report is an archived room */ // eslint-disable-next-line @typescript-eslint/no-unused-vars -function isArchivedRoom(report: OnyxInputOrEntry, reportNameValuePairs?: OnyxInputOrEntry): boolean { +function isArchivedNonExpenseReport(report: OnyxInputOrEntry, reportNameValuePairs?: OnyxInputOrEntry): boolean { return !isExpenseReport(report) && !!report?.private_isArchived; } @@ -1472,13 +1472,21 @@ function isArchivedExpenseReport(report: OnyxInputOrEntry): boolean { return isExpenseReport(report) && !!report?.private_isArchived; } +/** + * Whether the provided report is an archived report + */ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function isArchivedAnyReport(report: OnyxInputOrEntry, reportNameValuePairs?: OnyxInputOrEntry): boolean { + return !!report?.private_isArchived; +} + /** * Whether the report with the provided reportID is an archived room */ function isArchivedRoomWithID(reportID?: string) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const report = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID || -1}`]; - return isArchivedRoom(report, getReportNameValuePairs(reportID)); + return isArchivedNonExpenseReport(report, getReportNameValuePairs(reportID)); } /** @@ -1789,7 +1797,7 @@ function getChildReportNotificationPreference(reportAction: OnyxInputOrEntry): boolean { - if (!isMoneyRequestReport(moneyRequestReport) || isArchivedRoom(moneyRequestReport)) { + if (!isMoneyRequestReport(moneyRequestReport) || isArchivedAnyReport(moneyRequestReport)) { return false; } @@ -2389,7 +2397,7 @@ function getIcons( }; return [domainIcon]; } - if (isAdminRoom(report) || isAnnounceRoom(report) || isChatRoom(report) || isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { + if (isAdminRoom(report) || isAnnounceRoom(report) || isChatRoom(report) || isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) { const icons = [getWorkspaceIcon(report, policy)]; if (isInvoiceRoom(report)) { @@ -2777,8 +2785,8 @@ function getReasonAndReportActionThatRequiresAttention( } if ( - isArchivedRoom(optionOrReport, getReportNameValuePairs(optionOrReport?.reportID)) || - isArchivedRoom(getReportOrDraftReport(optionOrReport.parentReportID), getReportNameValuePairs(optionOrReport?.reportID)) + isArchivedAnyReport(optionOrReport, getReportNameValuePairs(optionOrReport?.reportID)) || + isArchivedAnyReport(getReportOrDraftReport(optionOrReport.parentReportID), getReportNameValuePairs(optionOrReport?.reportID)) ) { return null; } @@ -2909,7 +2917,7 @@ function getPolicyExpenseChatName(report: OnyxEntry, policy?: OnyxEntry< // If this user is not admin and this policy expense chat has been archived because of account merging, this must be an old workspace chat // of the account which was merged into the current user's account. Use the name of the policy as the name of the report. - if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { + if (isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) { const lastAction = ReportActionsUtils.getLastVisibleAction(report?.reportID ?? '-1'); const archiveReason = ReportActionsUtils.isClosedAction(lastAction) ? ReportActionsUtils.getOriginalMessage(lastAction)?.reason : CONST.REPORT.ARCHIVE_REASON.DEFAULT; if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED && policyExpenseChatRole !== CONST.POLICY.ROLE.ADMIN) { @@ -3978,7 +3986,7 @@ function getReportName( if (isChatThread(report)) { if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction)) { formattedName = getTransactionReportName(parentReportAction); - if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { + if (isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) { formattedName += ` (${Localize.translateLocal('common.archived')})`; } return formatReportLastMessageText(formattedName); @@ -4007,7 +4015,7 @@ function getReportName( if (isAdminRoom(report) || isUserCreatedPolicyRoom(report)) { return getAdminRoomInvitedParticipants(parentReportAction, reportActionMessage); } - if (reportActionMessage && isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { + if (reportActionMessage && isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) { return `${reportActionMessage} (${Localize.translateLocal('common.archived')})`; } if (!isEmptyObject(parentReportAction) && ReportActionsUtils.isModifiedExpenseAction(parentReportAction)) { @@ -4056,7 +4064,7 @@ function getReportName( formattedName = getInvoicesChatName(report, invoiceReceiverPolicy); } - if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { + if (isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) { formattedName += ` (${Localize.translateLocal('common.archived')})`; } @@ -4132,7 +4140,7 @@ function getChatRoomSubtitle(report: OnyxEntry): string | undefined { if ((isPolicyExpenseChat(report) && !!report?.isOwnPolicyExpenseChat) || isExpenseReport(report)) { return Localize.translateLocal('workspace.common.workspace'); } - if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { + if (isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) { return report?.oldPolicyName ?? ''; } return getPolicyName(report); @@ -4158,7 +4166,7 @@ function getParentNavigationSubtitle(report: OnyxEntry, invoiceReceiverP if (isInvoiceReport(report) || isInvoiceRoom(parentReport)) { let reportName = `${getPolicyName(parentReport)} & ${getInvoicePayerName(parentReport, invoiceReceiverPolicy)}`; - if (isArchivedRoom(parentReport, getReportNameValuePairs(parentReport?.reportID))) { + if (isArchivedNonExpenseReport(parentReport, getReportNameValuePairs(parentReport?.reportID))) { reportName += ` (${Localize.translateLocal('common.archived')})`; } @@ -6292,7 +6300,7 @@ function isIOUOwnedByCurrentUser(report: OnyxEntry, allReportsDict?: Ony */ function canSeeDefaultRoom(report: OnyxEntry, policies: OnyxCollection, betas: OnyxEntry): boolean { // Include archived rooms - if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { + if (isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) { return true; } @@ -6432,7 +6440,7 @@ function getAllReportActionsErrorsAndReportActionThatRequiresAttention(report: O ? undefined : allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID ?? '-1'}`]?.[report.parentReportActionID ?? '-1']; - if (!isArchivedRoom(report)) { + if (!isArchivedAnyReport(report)) { if (ReportActionsUtils.wasActionTakenByCurrentUser(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction)) { const transactionID = ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID : null; const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]; @@ -6543,7 +6551,7 @@ function reasonForReportToBeInOptionList({ // So we allow showing rooms with no participants–in any other circumstances we should never have these reports with no participants in Onyx. !isChatRoom(report) && !isChatThread(report) && - !isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) && + !isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) && !isMoneyRequestReport(report) && !isTaskReport(report) && !isSelfDM(report) && @@ -6630,7 +6638,7 @@ function reasonForReportToBeInOptionList({ } // Archived reports should always be shown when in default (most recent) mode. This is because you should still be able to access and search for the chats to find them. - if (isInDefaultMode && isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { + if (isInDefaultMode && isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) { return CONST.REPORT_IN_LHN_REASONS.IS_ARCHIVED; } @@ -6712,7 +6720,7 @@ function getChatByParticipants(newParticipantList: number[], reports: OnyxCollec */ function getInvoiceChatByParticipants(policyID: string, receiverID: string | number, reports: OnyxCollection = ReportConnection.getAllReports()): OnyxEntry { return Object.values(reports ?? {}).find((report) => { - if (!report || !isInvoiceRoom(report) || isArchivedRoom(report)) { + if (!report || !isInvoiceRoom(report) || isArchivedNonExpenseReport(report)) { return false; } @@ -6800,7 +6808,7 @@ function canFlagReportAction(reportAction: OnyxInputOrEntry, repor function shouldShowFlagComment(reportAction: OnyxInputOrEntry, report: OnyxInputOrEntry): boolean { return ( canFlagReportAction(reportAction, report?.reportID) && - !isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) && + !isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) && !chatIncludesChronos(report) && !isConciergeChatReport(report) && reportAction?.actorAccountID !== CONST.ACCOUNT_ID.CONCIERGE @@ -7123,7 +7131,7 @@ function canLeaveInvoiceRoom(report: OnyxEntry): boolean { */ function canLeaveRoom(report: OnyxEntry, isPolicyEmployee: boolean): boolean { if (isInvoiceRoom(report)) { - if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID))) { + if (isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) { return false; } @@ -7194,7 +7202,7 @@ function getWhisperDisplayNames(participantAccountIDs?: number[]): string | unde * Show subscript on workspace chats / threads and expense requests */ function shouldReportShowSubscript(report: OnyxEntry): boolean { - if (isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) && !isWorkspaceThread(report)) { + if (isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) && !isWorkspaceThread(report)) { return false; } @@ -7275,7 +7283,7 @@ function canUserPerformWriteAction(report: OnyxEntry) { } const reportNameValuePairs = getReportNameValuePairs(report?.reportID); - return !isArchivedRoom(report, reportNameValuePairs) && isEmptyObject(reportErrors) && report && isAllowedToComment(report) && !isAnonymousUser && canWriteInReport(report); + return !isArchivedNonExpenseReport(report, reportNameValuePairs) && isEmptyObject(reportErrors) && report && isAllowedToComment(report) && !isAnonymousUser && canWriteInReport(report); } /** @@ -7348,7 +7356,7 @@ function getAllWorkspaceReports(policyID: string): Array> { function shouldDisableRename(report: OnyxEntry): boolean { if ( isDefaultRoom(report) || - isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) || + isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) || isPublicRoom(report) || isThread(report) || isMoneyRequest(report) || @@ -7376,14 +7384,20 @@ function shouldDisableRename(report: OnyxEntry): boolean { * @param policy - the workspace the report is on, null if the user isn't a member of the workspace */ function canEditWriteCapability(report: OnyxEntry, policy: OnyxEntry): boolean { - return PolicyUtils.isPolicyAdmin(policy) && !isAdminRoom(report) && !isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) && !isThread(report) && !isInvoiceRoom(report); + return ( + PolicyUtils.isPolicyAdmin(policy) && + !isAdminRoom(report) && + !isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) && + !isThread(report) && + !isInvoiceRoom(report) + ); } /** * @param policy - the workspace the report is on, null if the user isn't a member of the workspace */ function canEditRoomVisibility(report: OnyxEntry, policy: OnyxEntry): boolean { - return PolicyUtils.isPolicyAdmin(policy) && !isArchivedRoom(report, getReportNameValuePairs(report?.reportID)); + return PolicyUtils.isPolicyAdmin(policy) && !isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)); } /** @@ -7592,7 +7606,7 @@ function isDeprecatedGroupDM(report: OnyxEntry): boolean { !isTaskReport(report) && !isInvoiceReport(report) && !isMoneyRequestReport(report) && - !isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) && + !isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) && !Object.values(CONST.REPORT.CHAT_TYPE).some((chatType) => chatType === getChatType(report)) && Object.keys(report.participants ?? {}) .map(Number) @@ -7656,7 +7670,7 @@ function getRoom(type: ValueOf, policyID: string) function canEditReportDescription(report: OnyxEntry, policy: OnyxEntry): boolean { return ( !isMoneyRequestReport(report) && - !isArchivedRoom(report, getReportNameValuePairs(report?.reportID)) && + !isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) && isChatRoom(report) && !isChatThread(report) && !isEmpty(policy) && @@ -7822,7 +7836,7 @@ function shouldDisableThread(reportAction: OnyxInputOrEntry, repor const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction); const isIOUAction = ReportActionsUtils.isMoneyRequestAction(reportAction); const isWhisperAction = ReportActionsUtils.isWhisperAction(reportAction) || ReportActionsUtils.isActionableTrackExpense(reportAction); - const isArchivedReport = isArchivedRoom(getReportOrDraftReport(reportID), getReportNameValuePairs(reportID)); + const isArchivedReport = isArchivedNonExpenseReport(getReportOrDraftReport(reportID), getReportNameValuePairs(reportID)); const isActionDisabled = CONST.REPORT.ACTIONS.THREAD_DISABLED.some((action: string) => action === reportAction?.actionName); return ( @@ -7957,7 +7971,7 @@ function getQuickActionDetails( policyChatForActivePolicy: Report | undefined, reportNameValuePairs: ReportNameValuePairs, ): {quickActionAvatars: Icon[]; hideQABSubtitle: boolean} { - const isValidQuickActionReport = !(isEmptyObject(quickActionReport) || isArchivedRoom(quickActionReport, reportNameValuePairs)); + const isValidQuickActionReport = !(isEmptyObject(quickActionReport) || isArchivedNonExpenseReport(quickActionReport, reportNameValuePairs)); let hideQABSubtitle = false; let quickActionAvatars: Icon[] = []; if (isValidQuickActionReport) { @@ -8618,8 +8632,9 @@ export { isAllowedToComment, isAllowedToSubmitDraftExpenseReport, isAnnounceRoom, - isArchivedRoom, + isArchivedNonExpenseReport, isArchivedExpenseReport, + isArchivedAnyReport, isArchivedRoomWithID, isClosedReport, isCanceledTaskReport, diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 806cebd9bf7f..9fed3733fe97 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -194,7 +194,7 @@ function getOrderedReportIDs( errorReports.push(miniReport); } else if (hasValidDraftComment(report?.reportID ?? '-1')) { draftReports.push(miniReport); - } else if (ReportUtils.isArchivedRoom(report, reportNameValuePairs)) { + } else if (ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs)) { archivedReports.push(miniReport); } else { nonArchivedReports.push(miniReport); diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 69de0d20a3dc..7acd58066f92 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6784,7 +6784,7 @@ function canIOUBePaid( ) { const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport); const reportNameValuePairs = ReportUtils.getReportNameValuePairs(chatReport?.reportID); - const isChatReportArchived = ReportUtils.isArchivedRoom(chatReport, reportNameValuePairs); + const isChatReportArchived = ReportUtils.isArchivedNonExpenseReport(chatReport, reportNameValuePairs); const iouSettled = ReportUtils.isSettled(iouReport?.reportID); if (isEmptyObject(iouReport)) { diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 664bdb3779a6..7be4ab61fa72 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1165,7 +1165,7 @@ function canModifyTask(taskReport: OnyxEntry, sessionAccountID const parentReport = getParentReport(taskReport); const reportNameValuePairs = ReportUtils.getReportNameValuePairs(parentReport?.reportID); - if (ReportUtils.isArchivedRoom(parentReport, reportNameValuePairs)) { + if (ReportUtils.isArchivedNonExpenseReport(parentReport, reportNameValuePairs)) { return false; } diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 296a2d51e283..00081880f8a7 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -125,7 +125,7 @@ function ReportDetailsPage({policies, report, route}: ReportDetailsPageProps) { const isUserCreatedPolicyRoom = useMemo(() => ReportUtils.isUserCreatedPolicyRoom(report), [report]); const isDefaultRoom = useMemo(() => ReportUtils.isDefaultRoom(report), [report]); const isChatThread = useMemo(() => ReportUtils.isChatThread(report), [report]); - const isArchivedRoom = useMemo(() => ReportUtils.isArchivedRoom(report, reportNameValuePairs), [report, reportNameValuePairs]); + const isArchivedRoom = useMemo(() => ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs), [report, reportNameValuePairs]); const isMoneyRequestReport = useMemo(() => ReportUtils.isMoneyRequestReport(report), [report]); const isMoneyRequest = useMemo(() => ReportUtils.isMoneyRequest(report), [report]); const isInvoiceReport = useMemo(() => ReportUtils.isInvoiceReport(report), [report]); @@ -223,7 +223,11 @@ function ReportDetailsPage({policies, report, route}: ReportDetailsPageProps) { const shouldShowDeleteButton = shouldShowTaskDeleteButton || canDeleteRequest; const canUnapproveRequest = - ReportUtils.isExpenseReport(report) && (ReportUtils.isReportManager(report) || isPolicyAdmin) && ReportUtils.isReportApproved(report) && !PolicyUtils.isSubmitAndClose(policy); + ReportUtils.isExpenseReport(report) && + !ReportUtils.isArchivedExpenseReport(report) && + (ReportUtils.isReportManager(report) || isPolicyAdmin) && + ReportUtils.isReportApproved(report) && + !PolicyUtils.isSubmitAndClose(policy); useEffect(() => { if (canDeleteRequest) { @@ -295,7 +299,8 @@ function ReportDetailsPage({policies, report, route}: ReportDetailsPageProps) { const isPayer = ReportUtils.isPayer(session, moneyRequestReport); const isSettled = ReportUtils.isSettled(moneyRequestReport?.reportID ?? '-1'); - const shouldShowCancelPaymentButton = caseID === CASES.MONEY_REPORT && isPayer && isSettled && ReportUtils.isExpenseReport(moneyRequestReport); + const shouldShowCancelPaymentButton = + caseID === CASES.MONEY_REPORT && isPayer && isSettled && !ReportUtils.isArchivedExpenseReport(moneyRequestReport) && ReportUtils.isExpenseReport(moneyRequestReport); const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport?.chatReportID ?? '-1'}`); const iouTransactionID = ReportActionsUtils.isMoneyRequestAction(requestParentReportAction) @@ -639,7 +644,7 @@ function ReportDetailsPage({policies, report, route}: ReportDetailsPageProps) { const shouldShowHoldAction = caseID !== CASES.DEFAULT && (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) && - !ReportUtils.isArchivedRoom(transactionThreadReportID ? report : parentReport, parentReportNameValuePairs); + !ReportUtils.isArchivedAnyReport(transactionThreadReportID ? report : parentReport, parentReportNameValuePairs); const canJoin = ReportUtils.canJoinChat(report, parentReportAction, policy); diff --git a/src/pages/ReportParticipantsPage.tsx b/src/pages/ReportParticipantsPage.tsx index 1c91023f2d6f..6e04aa048b1e 100755 --- a/src/pages/ReportParticipantsPage.tsx +++ b/src/pages/ReportParticipantsPage.tsx @@ -363,7 +363,7 @@ function ReportParticipantsPage({report, route}: ReportParticipantsPageProps) { style={[styles.defaultModalContainer]} testID={ReportParticipantsPage.displayName} > - + { diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index 969e1a90ec3b..be8cdf1b3603 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -215,7 +215,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto fullTitle={title} displayNamesWithTooltips={displayNamesWithTooltips} tooltipEnabled - numberOfLines={1} + numberOfLines={2} textStyles={[styles.headerText, styles.pre]} shouldUseFullTitle={isChatRoom || isPolicyExpenseChat || isChatThread || isTaskReport || shouldUseGroupTitle} renderAdditionalText={renderAdditionalText} diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index 2e92669aa8c5..f9decffd35f1 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -178,7 +178,7 @@ function BaseReportActionContextMenu({ const isMoneyRequestOrReport = isMoneyRequestReport || isSingleTransactionView; const areHoldRequirementsMet = - !isInvoiceReport && isMoneyRequestOrReport && !ReportUtils.isArchivedRoom(transactionThreadReportID ? childReport : parentReport, parentReportNameValuePairs); + !isInvoiceReport && isMoneyRequestOrReport && !ReportUtils.isArchivedAnyReport(transactionThreadReportID ? childReport : parentReport, parentReportNameValuePairs); const shouldEnableArrowNavigation = !isMini && (isVisible || shouldKeepOpen); let filteredContextMenuActions = ContextMenuActions.filter( diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 559d635f73fe..fc0685f135fb 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -772,7 +772,7 @@ function ReportActionItem({ ref={textInputRef} shouldDisableEmojiPicker={ (ReportUtils.chatIncludesConcierge(report) && User.isBlockedFromConcierge(blockedFromConcierge)) || - ReportUtils.isArchivedRoom(report, reportNameValuePairs) + ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs) } isGroupPolicyReport={!!report?.policyID && report.policyID !== CONST.POLICY.ID_FAKE} /> diff --git a/src/pages/home/report/ReportActionsList.tsx b/src/pages/home/report/ReportActionsList.tsx index 8ddea8e7e940..03e916688e55 100644 --- a/src/pages/home/report/ReportActionsList.tsx +++ b/src/pages/home/report/ReportActionsList.tsx @@ -561,7 +561,7 @@ function ReportActionsList({ const newMessageTimeReference = lastMessageTime.current && report.lastReadTime && lastMessageTime.current > report.lastReadTime ? userActiveSince.current : report.lastReadTime; lastMessageTime.current = null; - const isArchivedReport = ReportUtils.isArchivedRoom(report); + const isArchivedReport = ReportUtils.isArchivedNonExpenseReport(report); const hasNewMessagesInView = scrollingVerticalOffset.current < MSG_VISIBLE_THRESHOLD; const hasUnreadReportAction = sortedVisibleReportActions.some( (reportAction) => @@ -626,7 +626,7 @@ function ReportActionsList({ // Native mobile does not render updates flatlist the changes even though component did update called. // To notify there something changes we can use extraData prop to flatlist const extraData = useMemo( - () => [shouldUseNarrowLayout ? unreadMarkerReportActionID : undefined, ReportUtils.isArchivedRoom(report, reportNameValuePairs)], + () => [shouldUseNarrowLayout ? unreadMarkerReportActionID : undefined, ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs)], [unreadMarkerReportActionID, shouldUseNarrowLayout, report, reportNameValuePairs], ); const hideComposer = !ReportUtils.canUserPerformWriteAction(report); diff --git a/src/pages/home/report/ReportFooter.tsx b/src/pages/home/report/ReportFooter.tsx index c087510374be..d8ae51d9c7b4 100644 --- a/src/pages/home/report/ReportFooter.tsx +++ b/src/pages/home/report/ReportFooter.tsx @@ -106,7 +106,7 @@ function ReportFooter({ const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const chatFooterStyles = {...styles.chatFooter, minHeight: !isOffline ? CONST.CHAT_FOOTER_MIN_HEIGHT : 0}; - const isArchivedRoom = ReportUtils.isArchivedRoom(report, reportNameValuePairs); + const isArchivedRoom = ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs); const isSmallSizeLayout = windowWidth - (shouldUseNarrowLayout ? 0 : variables.sideBarWidth) < variables.anonymousReportFooterBreakpoint; diff --git a/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx b/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx index 2fed275045bc..c9944dabbaf4 100644 --- a/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx +++ b/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx @@ -56,7 +56,7 @@ export default function (pageTitle: TranslationPaths) { // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundPage = useMemo(() => { // Show not found view if the report is archived, or if the note is not of current user or if report is a self DM. - if (ReportUtils.isArchivedRoom(report, reportNameValuePairs) || isOtherUserNote || ReportUtils.isSelfDM(report)) { + if (ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs) || isOtherUserNote || ReportUtils.isSelfDM(report)) { return true; } diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 93d582c391c5..09b9eda13b12 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -178,7 +178,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl const {canUseSpotnanaTravel, canUseCombinedTrackSubmit} = usePermissions(); const canSendInvoice = useMemo(() => PolicyUtils.canSendInvoice(allPolicies as OnyxCollection, session?.email), [allPolicies, session?.email]); - const isValidReport = !(isEmptyObject(quickActionReport) || ReportUtils.isArchivedRoom(quickActionReport, reportNameValuePairs)); + const isValidReport = !(isEmptyObject(quickActionReport) || ReportUtils.isArchivedNonExpenseReport(quickActionReport, reportNameValuePairs)); const {environment} = useEnvironment(); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); const navatticURL = getNavatticURL(environment, introSelected?.choice); diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 70a9c545dc8e..74c3572586a6 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -80,7 +80,7 @@ function IOURequestStepAmount({ return false; } - return !(ReportUtils.isArchivedRoom(report, reportNameValuePairs) || ReportUtils.isPolicyExpenseChat(report)); + return !(ReportUtils.isArchivedAnyReport(report, reportNameValuePairs) || ReportUtils.isPolicyExpenseChat(report)); }, [report, skipConfirmation, reportNameValuePairs]); useFocusEffect( @@ -169,7 +169,7 @@ function IOURequestStepAmount({ // In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. // If the user is started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. - if (report?.reportID && !ReportUtils.isArchivedRoom(report, reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { + if (report?.reportID && !ReportUtils.isArchivedAnyReport(report, reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { const participantAccountID = participant?.accountID ?? -1; diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index ae3ecff9adb2..196be84ff9a4 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -164,7 +164,7 @@ function IOURequestStepDistance({ return ( iouType !== CONST.IOU.TYPE.SPLIT && - !ReportUtils.isArchivedRoom(report, reportNameValuePairs) && + !ReportUtils.isArchivedAnyReport(report, reportNameValuePairs) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))) ); }, [report, skipConfirmation, policy, reportNameValuePairs, iouType]); @@ -296,7 +296,7 @@ function IOURequestStepDistance({ // In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. // If the user started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. - if (report?.reportID && !ReportUtils.isArchivedRoom(report, reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { + if (report?.reportID && !ReportUtils.isArchivedAnyReport(report, reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { const participantAccountID = participant?.accountID ?? -1; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 418474e117ed..4183f1e786a1 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -97,7 +97,8 @@ function IOURequestStepScan({ } return ( - !ReportUtils.isArchivedRoom(report, reportNameValuePairs) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))) + !ReportUtils.isArchivedAnyReport(report, reportNameValuePairs) && + !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))) ); }, [report, skipConfirmation, policy, reportNameValuePairs]); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 375936b05c1a..5bda64365a72 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -108,7 +108,8 @@ function IOURequestStepScan({ } return ( - !ReportUtils.isArchivedRoom(report, reportNameValuePairs) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))) + !ReportUtils.isArchivedAnyReport(report, reportNameValuePairs) && + !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))) ); }, [report, skipConfirmation, policy, reportNameValuePairs]); diff --git a/src/pages/settings/Report/NotificationPreferencePage.tsx b/src/pages/settings/Report/NotificationPreferencePage.tsx index 416d710d4966..52067ae6decb 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.tsx +++ b/src/pages/settings/Report/NotificationPreferencePage.tsx @@ -28,7 +28,7 @@ function NotificationPreferencePage({report}: NotificationPreferencePageProps) { const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const currentNotificationPreference = ReportUtils.getReportNotificationPreference(report); const shouldDisableNotificationPreferences = - ReportUtils.isArchivedRoom(report, reportNameValuePairs) || + ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs) || ReportUtils.isSelfDM(report) || (!isMoneyRequestReport && currentNotificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN); const notificationPreferenceOptions = Object.values(CONST.REPORT.NOTIFICATION_PREFERENCE) diff --git a/src/pages/settings/Report/ReportSettingsPage.tsx b/src/pages/settings/Report/ReportSettingsPage.tsx index c407788dce65..36e567b75b1d 100644 --- a/src/pages/settings/Report/ReportSettingsPage.tsx +++ b/src/pages/settings/Report/ReportSettingsPage.tsx @@ -33,7 +33,7 @@ function ReportSettingsPage({report, policies, route}: ReportSettingsPageProps) const linkedWorkspace = useMemo(() => Object.values(policies ?? {}).find((policy) => policy && policy.id === report?.policyID), [policies, report?.policyID]); const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); - const shouldDisableSettings = isEmptyObject(report) || ReportUtils.isArchivedRoom(report, reportNameValuePairs) || ReportUtils.isSelfDM(report); + const shouldDisableSettings = isEmptyObject(report) || ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs) || ReportUtils.isSelfDM(report); const notificationPreferenceValue = ReportUtils.getReportNotificationPreference(report); const notificationPreference = notificationPreferenceValue && notificationPreferenceValue !== CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN diff --git a/src/pages/settings/Report/VisibilityPage.tsx b/src/pages/settings/Report/VisibilityPage.tsx index 07c05d1b8de1..242426a76c20 100644 --- a/src/pages/settings/Report/VisibilityPage.tsx +++ b/src/pages/settings/Report/VisibilityPage.tsx @@ -28,7 +28,7 @@ function VisibilityPage({report}: VisibilityProps) { const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || -1}`); const shouldGoBackToDetailsPage = useRef(false); - const shouldDisableVisibility = ReportUtils.isArchivedRoom(report, reportNameValuePairs); + const shouldDisableVisibility = ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs); const {translate} = useLocalize(); const visibilityOptions = useMemo( diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 878a2dcd6b22..f48b8cf1bbb9 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -85,6 +85,7 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) { const connectionNames = CONST.POLICY.CONNECTIONS.NAME; const accountingIntegrations = Object.values(connectionNames); + const connectedIntegration = getConnectedIntegration(policy, accountingIntegrations) ?? connectionSyncProgress?.connectionName; const synchronizationError = connectedIntegration && getSynchronizationErrorMessage(policy, connectedIntegration, isSyncInProgress, translate, styles); From 367f750ba91ac1aa991a7fd14a80a477ba63940a Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Fri, 22 Nov 2024 00:59:28 +0300 Subject: [PATCH 07/29] changed function name --- src/components/MoneyReportHeader.tsx | 2 +- src/components/ReportActionItem/ReportPreview.tsx | 2 +- src/libs/ReportUtils.ts | 4 ++-- .../home/report/ContextMenu/BaseReportActionContextMenu.tsx | 2 +- src/pages/home/report/ReportActionItem.tsx | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index b60ef426d8c8..f7373d926b5f 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -118,7 +118,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const shouldShowBrokenConnectionViolation = TransactionUtils.shouldShowBrokenConnectionViolation(transaction?.transactionID ?? '-1', moneyRequestReport, policy); const hasOnlyHeldExpenses = ReportUtils.hasOnlyHeldExpenses(moneyRequestReport?.reportID ?? ''); const isPayAtEndExpense = TransactionUtils.isPayAtEndExpense(transaction); - const isArchivedReport = ReportUtils.isArchivedRoomWithID(moneyRequestReport?.reportID); + const isArchivedReport = ReportUtils.isArchivedNonExpenseReportWithID(moneyRequestReport?.reportID); const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(moneyRequestReport); const [archiveReason] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport?.reportID ?? '-1'}`, {selector: ReportUtils.getArchiveReason}); diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index 1fd63ed37cd2..c1a9395747ad 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -184,7 +184,7 @@ function ReportPreview({ } const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(iouReport); - const isArchivedReport = ReportUtils.isArchivedRoomWithID(iouReportID); + const isArchivedReport = ReportUtils.isArchivedNonExpenseReportWithID(iouReportID); const currentUserAccountID = getCurrentUserAccountID(); const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; const shouldShowSubmitButton = diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 6833b875dd1b..64e7339090f5 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1483,7 +1483,7 @@ function isArchivedAnyReport(report: OnyxInputOrEntry, reportNameValuePa /** * Whether the report with the provided reportID is an archived room */ -function isArchivedRoomWithID(reportID?: string) { +function isArchivedNonExpenseReportWithID(reportID?: string) { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const report = ReportConnection.getAllReports()?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID || -1}`]; return isArchivedNonExpenseReport(report, getReportNameValuePairs(reportID)); @@ -8635,7 +8635,7 @@ export { isArchivedNonExpenseReport, isArchivedExpenseReport, isArchivedAnyReport, - isArchivedRoomWithID, + isArchivedNonExpenseReportWithID, isClosedReport, isCanceledTaskReport, isChatReport, diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index f9decffd35f1..811d0c73acc6 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -276,7 +276,7 @@ function BaseReportActionContextMenu({ checkIfContextMenuActive?.(); setShouldKeepOpen(false); }, - ReportUtils.isArchivedRoomWithID(originalReportID), + ReportUtils.isArchivedNonExpenseReportWithID(originalReportID), ReportUtils.chatIncludesChronosWithID(originalReportID), undefined, undefined, diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index fc0685f135fb..8140f70c84c8 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -321,7 +321,7 @@ function ReportActionItem({ setIsContextMenuActive(ReportActionContextMenu.isActiveReportAction(action.reportActionID)); }, [action.reportActionID]); - const isArchivedRoom = ReportUtils.isArchivedRoomWithID(originalReportID); + const isArchivedRoom = ReportUtils.isArchivedNonExpenseReportWithID(originalReportID); const disabledActions = useMemo(() => (!ReportUtils.canWriteInReport(report) ? RestrictedReadOnlyContextMenuActions : []), [report]); const isChronosReport = ReportUtils.chatIncludesChronosWithID(originalReportID); /** From 4a8865d339c6cb15531e861dcf29a02f886c5aec Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 25 Nov 2024 15:20:48 +0300 Subject: [PATCH 08/29] minor fix --- src/libs/ReportUtils.ts | 3 ++- src/libs/actions/IOU.ts | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index abfaf6752976..cf49fa384b7c 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1470,7 +1470,8 @@ function isArchivedNonExpenseReport(report: OnyxInputOrEntry | SearchRep /** * Whether the provided report is an archived expense report */ -function isArchivedExpenseReport(report: OnyxInputOrEntry): boolean { +// eslint-disable-next-line @typescript-eslint/no-unused-vars +function isArchivedExpenseReport(report: OnyxInputOrEntry, reportNameValuePairs?: OnyxInputOrEntry): boolean { return isExpenseReport(report) && !!report?.private_isArchived; } diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index fca868dc66a4..39b374d0f751 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6802,12 +6802,8 @@ function canApproveIOU( const isOpenExpenseReport = ReportUtils.isOpenExpenseReport(iouReport); const isApproved = ReportUtils.isReportApproved(iouReport); const iouSettled = ReportUtils.isSettled(iouReport?.reportID); -<<<<<<< HEAD - const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(iouReport); -======= const reportNameValuePairs = chatReportRNVP ?? ReportUtils.getReportNameValuePairs(iouReport?.reportID); - const isArchivedReport = ReportUtils.isArchivedRoom(iouReport, reportNameValuePairs); ->>>>>>> main + const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(iouReport, reportNameValuePairs); let isTransactionBeingScanned = false; const reportTransactions = TransactionUtils.getAllReportTransactions(iouReport?.reportID); for (const transaction of reportTransactions) { From 76b27d1f08aee4047948ebb4f49ad0b74dc2e372 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 25 Nov 2024 16:31:17 +0300 Subject: [PATCH 09/29] updated based on comments --- src/components/MoneyReportHeader.tsx | 5 ++--- src/components/ReportActionItem/ReportPreview.tsx | 5 ++--- src/libs/ReportUtils.ts | 14 +++++++------- src/libs/actions/IOU.ts | 2 +- src/pages/ReportDetailsPage.tsx | 15 +++------------ .../ContextMenu/BaseReportActionContextMenu.tsx | 6 +----- .../iou/request/step/IOURequestStepAmount.tsx | 4 ++-- .../iou/request/step/IOURequestStepDistance.tsx | 4 ++-- .../step/IOURequestStepScan/index.native.tsx | 2 +- .../iou/request/step/IOURequestStepScan/index.tsx | 2 +- 10 files changed, 22 insertions(+), 37 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index f7373d926b5f..f823647f0200 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -118,8 +118,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const shouldShowBrokenConnectionViolation = TransactionUtils.shouldShowBrokenConnectionViolation(transaction?.transactionID ?? '-1', moneyRequestReport, policy); const hasOnlyHeldExpenses = ReportUtils.hasOnlyHeldExpenses(moneyRequestReport?.reportID ?? ''); const isPayAtEndExpense = TransactionUtils.isPayAtEndExpense(transaction); - const isArchivedReport = ReportUtils.isArchivedNonExpenseReportWithID(moneyRequestReport?.reportID); - const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(moneyRequestReport); + const isArchivedReport = ReportUtils.isArchivedReport(moneyRequestReport); const [archiveReason] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport?.reportID ?? '-1'}`, {selector: ReportUtils.getArchiveReason}); const getCanIOUBePaid = useCallback( @@ -145,7 +144,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const shouldShowSubmitButton = !!moneyRequestReport && - !isArchivedExpenseReport && + !isArchivedReport && isDraft && reimbursableSpend !== 0 && !hasAllPendingRTERViolations && diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index cbc930830221..a561092b4459 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -176,13 +176,12 @@ function ReportPreview({ formattedMerchant = null; } - const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(iouReport); - const isArchivedReport = ReportUtils.isArchivedNonExpenseReportWithID(iouReportID); + const isArchivedReport = ReportUtils.isArchivedReport(iouReport); const currentUserAccountID = getCurrentUserAccountID(); const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; const shouldShowSubmitButton = isOpenExpenseReport && - !isArchivedExpenseReport && + !isArchivedReport && reimbursableSpend !== 0 && !showRTERViolationMessage && !shouldShowBrokenConnectionViolation && diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index cf49fa384b7c..3052df4b88f2 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1479,7 +1479,7 @@ function isArchivedExpenseReport(report: OnyxInputOrEntry, reportNameVal * Whether the provided report is an archived report */ // eslint-disable-next-line @typescript-eslint/no-unused-vars -function isArchivedAnyReport(report: OnyxInputOrEntry | SearchReport, reportNameValuePairs?: OnyxInputOrEntry): boolean { +function isArchivedReport(report: OnyxInputOrEntry | SearchReport, reportNameValuePairs?: OnyxInputOrEntry): boolean { return !!report?.private_isArchived; } @@ -1793,7 +1793,7 @@ function getChildReportNotificationPreference(reportAction: OnyxInputOrEntry): boolean { - if (!isMoneyRequestReport(moneyRequestReport) || isArchivedAnyReport(moneyRequestReport)) { + if (!isMoneyRequestReport(moneyRequestReport) || isArchivedReport(moneyRequestReport)) { return false; } @@ -2780,8 +2780,8 @@ function getReasonAndReportActionThatRequiresAttention( } if ( - isArchivedAnyReport(optionOrReport, getReportNameValuePairs(optionOrReport?.reportID)) || - isArchivedAnyReport(getReportOrDraftReport(optionOrReport.parentReportID), getReportNameValuePairs(optionOrReport?.reportID)) + isArchivedReport(optionOrReport, getReportNameValuePairs(optionOrReport?.reportID)) || + isArchivedReport(getReportOrDraftReport(optionOrReport.parentReportID), getReportNameValuePairs(optionOrReport?.reportID)) ) { return null; } @@ -6430,7 +6430,7 @@ function getAllReportActionsErrorsAndReportActionThatRequiresAttention(report: O ? undefined : allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID ?? '-1'}`]?.[report.parentReportActionID ?? '-1']; - if (!isArchivedAnyReport(report)) { + if (!isArchivedReport(report)) { if (ReportActionsUtils.wasActionTakenByCurrentUser(parentReportAction) && ReportActionsUtils.isTransactionThread(parentReportAction)) { const transactionID = ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID : null; const transaction = allTransactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`]; @@ -6541,7 +6541,7 @@ function reasonForReportToBeInOptionList({ // So we allow showing rooms with no participants–in any other circumstances we should never have these reports with no participants in Onyx. !isChatRoom(report) && !isChatThread(report) && - !isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) && + !isArchivedReport(report, getReportNameValuePairs(report?.reportID)) && !isMoneyRequestReport(report) && !isTaskReport(report) && !isSelfDM(report) && @@ -8625,7 +8625,7 @@ export { isAnnounceRoom, isArchivedNonExpenseReport, isArchivedExpenseReport, - isArchivedAnyReport, + isArchivedReport, isArchivedNonExpenseReportWithID, isClosedReport, isCanceledTaskReport, diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 39b374d0f751..5b25ba5ba37a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6830,7 +6830,7 @@ function canIOUBePaid( ) { const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport); const reportNameValuePairs = chatReportRNVP ?? ReportUtils.getReportNameValuePairs(chatReport?.reportID); - const isChatReportArchived = ReportUtils.isArchivedAnyReport(chatReport, reportNameValuePairs); + const isChatReportArchived = ReportUtils.isArchivedReport(chatReport, reportNameValuePairs); const iouSettled = ReportUtils.isSettled(iouReport); if (isEmptyObject(iouReport)) { diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index b7bca918f368..37006f5f7b05 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -223,11 +223,7 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta const shouldShowDeleteButton = shouldShowTaskDeleteButton || canDeleteRequest; const canUnapproveRequest = - ReportUtils.isExpenseReport(report) && - !ReportUtils.isArchivedExpenseReport(report) && - (ReportUtils.isReportManager(report) || isPolicyAdmin) && - ReportUtils.isReportApproved(report) && - !PolicyUtils.isSubmitAndClose(policy); + ReportUtils.isExpenseReport(report) && (ReportUtils.isReportManager(report) || isPolicyAdmin) && ReportUtils.isReportApproved(report) && !PolicyUtils.isSubmitAndClose(policy); useEffect(() => { if (canDeleteRequest) { @@ -299,8 +295,7 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta const isPayer = ReportUtils.isPayer(session, moneyRequestReport); const isSettled = ReportUtils.isSettled(moneyRequestReport?.reportID ?? '-1'); - const shouldShowCancelPaymentButton = - caseID === CASES.MONEY_REPORT && isPayer && isSettled && !ReportUtils.isArchivedExpenseReport(moneyRequestReport) && ReportUtils.isExpenseReport(moneyRequestReport); + const shouldShowCancelPaymentButton = caseID === CASES.MONEY_REPORT && isPayer && isSettled && ReportUtils.isExpenseReport(moneyRequestReport); const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport?.chatReportID ?? '-1'}`); const iouTransactionID = ReportActionsUtils.isMoneyRequestAction(requestParentReportAction) @@ -641,11 +636,7 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta }, [report, icons, isMoneyRequestReport, isInvoiceReport, isGroupChat, isThread, styles]); const canHoldUnholdReportAction = ReportUtils.canHoldUnholdReportAction(moneyRequestAction); - const shouldShowHoldAction = - caseID !== CASES.DEFAULT && - (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) && - !ReportUtils.isArchivedAnyReport(transactionThreadReportID ? report : parentReport, parentReportNameValuePairs); - + const shouldShowHoldAction = caseID !== CASES.DEFAULT && (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest); const canJoin = ReportUtils.canJoinChat(report, parentReportAction, policy); const promotedActions = useMemo(() => { diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index e7fd62591f96..38807b44a6c4 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -176,16 +176,12 @@ function BaseReportActionContextMenu({ const moneyRequestAction = transactionThreadReportID ? requestParentReportAction : parentReportAction; - const [parentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${childReport?.parentReportID ?? '-1'}`); - const parentReport = ReportUtils.getReport(childReport?.parentReportID ?? '-1'); - const isMoneyRequest = useMemo(() => ReportUtils.isMoneyRequest(childReport), [childReport]); const isTrackExpenseReport = ReportUtils.isTrackExpenseReport(childReport); const isSingleTransactionView = isMoneyRequest || isTrackExpenseReport; const isMoneyRequestOrReport = isMoneyRequestReport || isSingleTransactionView; - const areHoldRequirementsMet = - !isInvoiceReport && isMoneyRequestOrReport && !ReportUtils.isArchivedAnyReport(transactionThreadReportID ? childReport : parentReport, parentReportNameValuePairs); + const areHoldRequirementsMet = !isInvoiceReport && isMoneyRequestOrReport; const shouldEnableArrowNavigation = !isMini && (isVisible || shouldKeepOpen); let filteredContextMenuActions = ContextMenuActions.filter( diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index 13dd41e67191..ebe79329ab1b 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -80,7 +80,7 @@ function IOURequestStepAmount({ return false; } - return !(ReportUtils.isArchivedAnyReport(report, reportNameValuePairs) || ReportUtils.isPolicyExpenseChat(report)); + return !(ReportUtils.isArchivedReport(report, reportNameValuePairs) || ReportUtils.isPolicyExpenseChat(report)); }, [report, skipConfirmation, reportNameValuePairs]); useFocusEffect( @@ -169,7 +169,7 @@ function IOURequestStepAmount({ // In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. // If the user is started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. - if (report?.reportID && !ReportUtils.isArchivedAnyReport(report, reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { + if (report?.reportID && !ReportUtils.isArchivedReport(report, reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { const participantAccountID = participant?.accountID ?? -1; diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 196be84ff9a4..3769fbc42d7f 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -164,7 +164,7 @@ function IOURequestStepDistance({ return ( iouType !== CONST.IOU.TYPE.SPLIT && - !ReportUtils.isArchivedAnyReport(report, reportNameValuePairs) && + !ReportUtils.isArchivedReport(report, reportNameValuePairs) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))) ); }, [report, skipConfirmation, policy, reportNameValuePairs, iouType]); @@ -296,7 +296,7 @@ function IOURequestStepDistance({ // In this case, the participants can be automatically assigned from the report and the user can skip the participants step and go straight // to the confirm step. // If the user started this flow using the Create expense option (combined submit/track flow), they should be redirected to the participants page. - if (report?.reportID && !ReportUtils.isArchivedAnyReport(report, reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { + if (report?.reportID && !ReportUtils.isArchivedReport(report, reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { const participantAccountID = participant?.accountID ?? -1; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 300871eb7db3..bc49945d41e0 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -97,7 +97,7 @@ function IOURequestStepScan({ } return ( - !ReportUtils.isArchivedAnyReport(report, reportNameValuePairs) && + !ReportUtils.isArchivedReport(report, reportNameValuePairs) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))) ); }, [report, skipConfirmation, policy, reportNameValuePairs]); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 26af3972bddc..b31459047289 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -108,7 +108,7 @@ function IOURequestStepScan({ } return ( - !ReportUtils.isArchivedAnyReport(report, reportNameValuePairs) && + !ReportUtils.isArchivedReport(report, reportNameValuePairs) && !(ReportUtils.isPolicyExpenseChat(report) && ((policy?.requiresCategory ?? false) || (policy?.requiresTag ?? false))) ); }, [report, skipConfirmation, policy, reportNameValuePairs]); From 9e365370168987cc6877b35a5791757f17a0ceaa Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 25 Nov 2024 16:54:42 +0300 Subject: [PATCH 10/29] updated hold cases --- src/pages/ReportDetailsPage.tsx | 5 ++++- .../home/report/ContextMenu/BaseReportActionContextMenu.tsx | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 37006f5f7b05..cf138535959f 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -636,7 +636,10 @@ function ReportDetailsPage({policies, report, route, reportMetadata}: ReportDeta }, [report, icons, isMoneyRequestReport, isInvoiceReport, isGroupChat, isThread, styles]); const canHoldUnholdReportAction = ReportUtils.canHoldUnholdReportAction(moneyRequestAction); - const shouldShowHoldAction = caseID !== CASES.DEFAULT && (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest); + const shouldShowHoldAction = + caseID !== CASES.DEFAULT && + (canHoldUnholdReportAction.canHoldRequest || canHoldUnholdReportAction.canUnholdRequest) && + !ReportUtils.isArchivedNonExpenseReport(transactionThreadReportID ? report : parentReport, parentReportNameValuePairs); const canJoin = ReportUtils.canJoinChat(report, parentReportAction, policy); const promotedActions = useMemo(() => { diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index 38807b44a6c4..e05414c3840d 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -175,13 +175,16 @@ function BaseReportActionContextMenu({ }, [parentReportAction, isMoneyRequestReport, isInvoiceReport, paginatedReportActions, transactionThreadReport?.parentReportActionID]); const moneyRequestAction = transactionThreadReportID ? requestParentReportAction : parentReportAction; + const [parentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${childReport?.parentReportID ?? '-1'}`); + const parentReport = ReportUtils.getReport(childReport?.parentReportID ?? '-1'); const isMoneyRequest = useMemo(() => ReportUtils.isMoneyRequest(childReport), [childReport]); const isTrackExpenseReport = ReportUtils.isTrackExpenseReport(childReport); const isSingleTransactionView = isMoneyRequest || isTrackExpenseReport; const isMoneyRequestOrReport = isMoneyRequestReport || isSingleTransactionView; - const areHoldRequirementsMet = !isInvoiceReport && isMoneyRequestOrReport; + const areHoldRequirementsMet = + !isInvoiceReport && isMoneyRequestOrReport && !ReportUtils.isArchivedNonExpenseReport(transactionThreadReportID ? childReport : parentReport, parentReportNameValuePairs); const shouldEnableArrowNavigation = !isMini && (isVisible || shouldKeepOpen); let filteredContextMenuActions = ContextMenuActions.filter( From eba01f47c0f29ff59a9ae884bc1296097889fb82 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 25 Nov 2024 17:00:47 +0300 Subject: [PATCH 11/29] fix lint --- src/libs/ReportUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 3052df4b88f2..9d3e62807f93 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -7825,14 +7825,14 @@ function shouldDisableThread(reportAction: OnyxInputOrEntry, repor const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction); const isIOUAction = ReportActionsUtils.isMoneyRequestAction(reportAction); const isWhisperAction = ReportActionsUtils.isWhisperAction(reportAction) || ReportActionsUtils.isActionableTrackExpense(reportAction); - const isArchivedReport = isArchivedNonExpenseReport(getReportOrDraftReport(reportID), getReportNameValuePairs(reportID)); + const isArchived = isArchivedNonExpenseReport(getReportOrDraftReport(reportID), getReportNameValuePairs(reportID)); const isActionDisabled = CONST.REPORT.ACTIONS.THREAD_DISABLED.some((action: string) => action === reportAction?.actionName); return ( isActionDisabled || isSplitBillAction || (isDeletedAction && !reportAction?.childVisibleActionCount) || - (isArchivedReport && !reportAction?.childVisibleActionCount) || + (isArchived && !reportAction?.childVisibleActionCount) || (isWhisperAction && !isReportPreviewAction && !isIOUAction) || isThreadReportParentAction ); From 76a715756b02142dd468dd3aab1318ea7700e297 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 27 Nov 2024 17:59:22 +0300 Subject: [PATCH 12/29] additional changes --- src/libs/ReportUtils.ts | 12 +++--------- src/libs/actions/Task.ts | 2 +- src/pages/home/HeaderView.tsx | 2 +- .../settings/Report/NotificationPreferencePage.tsx | 2 +- .../workspace/accounting/PolicyAccountingPage.tsx | 1 - 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 43205f71b75f..6a3ab9cf5fcf 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4134,7 +4134,7 @@ function getChatRoomSubtitle(report: OnyxEntry): string | undefined { if ((isPolicyExpenseChat(report) && !!report?.isOwnPolicyExpenseChat) || isExpenseReport(report)) { return Localize.translateLocal('workspace.common.workspace'); } - if (isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID))) { + if (isArchivedReport(report, getReportNameValuePairs(report?.reportID))) { return report?.oldPolicyName ?? ''; } return getPolicyName(report); @@ -7370,13 +7370,7 @@ function shouldDisableRename(report: OnyxEntry): boolean { * @param policy - the workspace the report is on, null if the user isn't a member of the workspace */ function canEditWriteCapability(report: OnyxEntry, policy: OnyxEntry): boolean { - return ( - PolicyUtils.isPolicyAdmin(policy) && - !isAdminRoom(report) && - !isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) && - !isThread(report) && - !isInvoiceRoom(report) - ); + return PolicyUtils.isPolicyAdmin(policy) && !isAdminRoom(report) && !isArchivedReport(report, getReportNameValuePairs(report?.reportID)) && !isThread(report) && !isInvoiceRoom(report); } /** @@ -7655,7 +7649,7 @@ function getRoom(type: ValueOf, policyID: string) function canEditReportDescription(report: OnyxEntry, policy: OnyxEntry): boolean { return ( !isMoneyRequestReport(report) && - !isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) && + !isArchivedReport(report, getReportNameValuePairs(report?.reportID)) && isChatRoom(report) && !isChatThread(report) && !isEmpty(policy) && diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 9355e827913c..9fe7e45008e9 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1178,7 +1178,7 @@ function canModifyTask(taskReport: OnyxEntry, sessionAccountID const parentReport = getParentReport(taskReport); const reportNameValuePairs = ReportUtils.getReportNameValuePairs(parentReport?.reportID); - if (ReportUtils.isArchivedNonExpenseReport(parentReport, reportNameValuePairs)) { + if (ReportUtils.isArchivedReport(parentReport, reportNameValuePairs)) { return false; } diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index be8cdf1b3603..969e1a90ec3b 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -215,7 +215,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto fullTitle={title} displayNamesWithTooltips={displayNamesWithTooltips} tooltipEnabled - numberOfLines={2} + numberOfLines={1} textStyles={[styles.headerText, styles.pre]} shouldUseFullTitle={isChatRoom || isPolicyExpenseChat || isChatThread || isTaskReport || shouldUseGroupTitle} renderAdditionalText={renderAdditionalText} diff --git a/src/pages/settings/Report/NotificationPreferencePage.tsx b/src/pages/settings/Report/NotificationPreferencePage.tsx index 52067ae6decb..f04317b065a9 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.tsx +++ b/src/pages/settings/Report/NotificationPreferencePage.tsx @@ -28,7 +28,7 @@ function NotificationPreferencePage({report}: NotificationPreferencePageProps) { const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const currentNotificationPreference = ReportUtils.getReportNotificationPreference(report); const shouldDisableNotificationPreferences = - ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs) || + ReportUtils.isArchivedReport(report, reportNameValuePairs) || ReportUtils.isSelfDM(report) || (!isMoneyRequestReport && currentNotificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN); const notificationPreferenceOptions = Object.values(CONST.REPORT.NOTIFICATION_PREFERENCE) diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 2852812a04a6..5586bad6f179 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -85,7 +85,6 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) { const connectionNames = CONST.POLICY.CONNECTIONS.NAME; const accountingIntegrations = Object.values(connectionNames); - const connectedIntegration = getConnectedIntegration(policy, accountingIntegrations) ?? connectionSyncProgress?.connectionName; const synchronizationError = connectedIntegration && getSynchronizationErrorMessage(policy, connectedIntegration, isSyncInProgress, translate, styles); From 1241ae3008735698f1943879cf40001aea9e6b07 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 27 Nov 2024 23:45:23 +0300 Subject: [PATCH 13/29] allowed actions for archived expense requests --- src/libs/ReportUtils.ts | 13 ++----------- src/libs/actions/IOU.ts | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 6a3ab9cf5fcf..80b8640bd9f1 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1463,15 +1463,7 @@ function isClosedExpenseReportWithNoExpenses(report: OnyxEntry): boolean */ // eslint-disable-next-line @typescript-eslint/no-unused-vars function isArchivedNonExpenseReport(report: OnyxInputOrEntry | SearchReport, reportNameValuePairs?: OnyxInputOrEntry): boolean { - return !isExpenseReport(report) && !!report?.private_isArchived; -} - -/** - * Whether the provided report is an archived expense report - */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function isArchivedExpenseReport(report: OnyxInputOrEntry, reportNameValuePairs?: OnyxInputOrEntry): boolean { - return isExpenseReport(report) && !!report?.private_isArchived; + return !(isExpenseReport(report) || isExpenseRequest(report)) && !!report?.private_isArchived; } /** @@ -6995,7 +6987,7 @@ function isGroupChatAdmin(report: OnyxEntry, accountID: number) { */ function getMoneyRequestOptions(report: OnyxEntry, policy: OnyxEntry, reportParticipants: number[], filterDeprecatedTypes = false): IOUType[] { // In any thread or task report, we do not allow any new expenses yet - if (isChatThread(report) || isTaskReport(report) || isInvoiceReport(report) || isSystemChat(report) || isArchivedExpenseReport(report)) { + if (isChatThread(report) || isTaskReport(report) || isInvoiceReport(report) || isSystemChat(report) || isArchivedReport(report)) { return []; } @@ -8614,7 +8606,6 @@ export { isAllowedToSubmitDraftExpenseReport, isAnnounceRoom, isArchivedNonExpenseReport, - isArchivedExpenseReport, isArchivedReport, isArchivedNonExpenseReportWithID, isClosedReport, diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 611904fa6780..5b9130a192ca 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -6832,7 +6832,7 @@ function canApproveIOU( const isApproved = ReportUtils.isReportApproved(iouReport); const iouSettled = ReportUtils.isSettled(iouReport?.reportID); const reportNameValuePairs = chatReportRNVP ?? ReportUtils.getReportNameValuePairs(iouReport?.reportID); - const isArchivedExpenseReport = ReportUtils.isArchivedExpenseReport(iouReport, reportNameValuePairs); + const isArchivedExpenseReport = ReportUtils.isArchivedReport(iouReport, reportNameValuePairs); const allViolations = violations ?? allTransactionViolations; const hasViolations = ReportUtils.hasViolations(iouReport?.reportID ?? '-1', allViolations); let isTransactionBeingScanned = false; From d68c6c8ab8d9140be6672282996e405935e6073a Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 9 Dec 2024 20:06:44 +0300 Subject: [PATCH 14/29] made more changes --- src/libs/ReportUtils.ts | 6 +++--- .../home/report/withReportAndPrivateNotesOrNotFound.tsx | 2 +- .../SidebarScreen/FloatingActionButtonAndPopover.tsx | 2 +- src/pages/settings/Report/NotificationPreferencePage.tsx | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 694170bd6ee2..5ec96e24552d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -7352,7 +7352,7 @@ function getAllWorkspaceReports(policyID: string): Array> { function shouldDisableRename(report: OnyxEntry): boolean { if ( isDefaultRoom(report) || - isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) || + isArchivedReport(report, getReportNameValuePairs(report?.reportID)) || isPublicRoom(report) || isThread(report) || isMoneyRequest(report) || @@ -7604,7 +7604,7 @@ function isDeprecatedGroupDM(report: OnyxEntry): boolean { !isTaskReport(report) && !isInvoiceReport(report) && !isMoneyRequestReport(report) && - !isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID)) && + !isArchivedReport(report, getReportNameValuePairs(report?.reportID)) && !Object.values(CONST.REPORT.CHAT_TYPE).some((chatType) => chatType === getChatType(report)) && Object.keys(report.participants ?? {}) .map(Number) @@ -7963,7 +7963,7 @@ function getQuickActionDetails( policyChatForActivePolicy: Report | undefined, reportNameValuePairs: ReportNameValuePairs, ): {quickActionAvatars: Icon[]; hideQABSubtitle: boolean} { - const isValidQuickActionReport = !(isEmptyObject(quickActionReport) || isArchivedNonExpenseReport(quickActionReport, reportNameValuePairs)); + const isValidQuickActionReport = !(isEmptyObject(quickActionReport) || isArchivedReport(quickActionReport, reportNameValuePairs)); let hideQABSubtitle = false; let quickActionAvatars: Icon[] = []; if (isValidQuickActionReport) { diff --git a/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx b/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx index 1769f6939338..ceb07d840896 100644 --- a/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx +++ b/src/pages/home/report/withReportAndPrivateNotesOrNotFound.tsx @@ -56,7 +56,7 @@ export default function (pageTitle: TranslationPaths) { // eslint-disable-next-line rulesdir/no-negated-variables const shouldShowNotFoundPage = useMemo(() => { // Show not found view if the report is archived, or if the note is not of current user or if report is a self DM. - if (ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs) || isOtherUserNote || ReportUtils.isSelfDM(report)) { + if (ReportUtils.isArchivedReport(report, reportNameValuePairs) || isOtherUserNote || ReportUtils.isSelfDM(report)) { return true; } diff --git a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx index 4086c1943f09..5e1768f3a92a 100644 --- a/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx +++ b/src/pages/home/sidebar/SidebarScreen/FloatingActionButtonAndPopover.tsx @@ -178,7 +178,7 @@ function FloatingActionButtonAndPopover({onHideCreateMenu, onShowCreateMenu}: Fl const {canUseSpotnanaTravel, canUseCombinedTrackSubmit} = usePermissions(); const canSendInvoice = useMemo(() => PolicyUtils.canSendInvoice(allPolicies as OnyxCollection, session?.email), [allPolicies, session?.email]); - const isValidReport = !(isEmptyObject(quickActionReport) || ReportUtils.isArchivedNonExpenseReport(quickActionReport, reportNameValuePairs)); + const isValidReport = !(isEmptyObject(quickActionReport) || ReportUtils.isArchivedReport(quickActionReport, reportNameValuePairs)); const {environment} = useEnvironment(); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); const navatticURL = getNavatticURL(environment, introSelected?.choice); diff --git a/src/pages/settings/Report/NotificationPreferencePage.tsx b/src/pages/settings/Report/NotificationPreferencePage.tsx index 2b1378ca3b14..3c69d2619c01 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.tsx +++ b/src/pages/settings/Report/NotificationPreferencePage.tsx @@ -27,7 +27,7 @@ function NotificationPreferencePage({report}: NotificationPreferencePageProps) { const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const currentNotificationPreference = ReportUtils.getReportNotificationPreference(report); const shouldDisableNotificationPreferences = - ReportUtils.isArchivedReport(report, reportNameValuePairs) || + ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs) || ReportUtils.isSelfDM(report) || (!isMoneyRequestReport && currentNotificationPreference === CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN); const notificationPreferenceOptions = Object.values(CONST.REPORT.NOTIFICATION_PREFERENCE) From f3a150a45a38f3979f73e08ee9ce549db7cd7558 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 6 Jan 2025 16:46:17 +0300 Subject: [PATCH 15/29] minor fix --- src/pages/home/report/PureReportActionItem.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index bb3e04a90b84..98fe51910e9f 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -905,7 +905,7 @@ function PureReportActionItem({ ref={textInputRef} shouldDisableEmojiPicker={ (ReportUtils.chatIncludesConcierge(report) && User.isBlockedFromConcierge(blockedFromConcierge)) || - ReportUtils.isArchivedRoom(report, reportNameValuePairs) + ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs) } isGroupPolicyReport={!!report?.policyID && report.policyID !== CONST.POLICY.ID_FAKE} /> From 2ccb1aac920bbf3bd6b17a9d89ed1952486fb18e Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 6 Jan 2025 17:14:34 +0300 Subject: [PATCH 16/29] minor fix --- src/libs/actions/Task.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 42537c232d6e..a5a93ef9d211 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -1256,7 +1256,7 @@ function canActionTask(taskReport: OnyxEntry, sessionAccountID const parentReport = getParentReport(taskReport); const reportNameValuePairs = ReportUtils.getReportNameValuePairs(parentReport?.reportID); - if (ReportUtils.isArchivedRoom(parentReport, reportNameValuePairs)) { + if (ReportUtils.isArchivedNonExpenseReport(parentReport, reportNameValuePairs)) { return false; } From 3d47bca80836996ba9410362a02ca00f19328125 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 6 Jan 2025 17:44:44 +0300 Subject: [PATCH 17/29] fix lint --- src/ROUTES.ts | 2 +- .../BaseAnchorForAttachmentsOnly.tsx | 9 +----- .../BrokenConnectionDescription.tsx | 2 +- .../HTMLRenderers/ImageRenderer.tsx | 6 ++-- .../HTMLRenderers/MentionUserRenderer.tsx | 9 +----- .../HTMLRenderers/PreRenderer.tsx | 9 +----- src/components/MoneyReportHeader.tsx | 29 ++++++++++--------- src/components/ShowContextMenuContext.ts | 2 +- src/libs/ReportUtils.ts | 2 +- src/libs/TransactionUtils/index.ts | 2 +- 10 files changed, 27 insertions(+), 45 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index d7774828a1c7..30d2b1908f2d 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -327,7 +327,7 @@ const ROUTES = { ATTACHMENTS: { route: 'attachment', getRoute: ( - reportID: string, + reportID: string | undefined, type: ValueOf, url: string, accountID?: number, diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index dc3841e2e8ee..60a488fbcd7a 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -51,14 +51,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP if (isDisabled) { return; } - showContextMenuForReport( - event, - anchor, - report?.reportID ?? '-1', - action, - checkIfContextMenuActive, - ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs), - ); + showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs)); }} shouldUseHapticsOnLongPress accessibilityLabel={displayName} diff --git a/src/components/BrokenConnectionDescription.tsx b/src/components/BrokenConnectionDescription.tsx index c54bd0058f99..bfcec0ed0d82 100644 --- a/src/components/BrokenConnectionDescription.tsx +++ b/src/components/BrokenConnectionDescription.tsx @@ -14,7 +14,7 @@ import TextLink from './TextLink'; type BrokenConnectionDescriptionProps = { /** Transaction id of the corresponding report */ - transactionID: string; + transactionID: string | undefined; /** Current report */ report: OnyxEntry; diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx index 5587bbed1094..8f62972841cb 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx @@ -96,7 +96,7 @@ function ImageRenderer({tnode}: ImageRendererProps) { {({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive, isDisabled}) => ( - {({reportID, accountID, type}) => ( + {({accountID, type}) => ( { @@ -105,7 +105,7 @@ function ImageRenderer({tnode}: ImageRendererProps) { } const attachmentLink = tnode.parent?.attributes?.href; - const route = ROUTES.ATTACHMENTS?.getRoute(reportID ?? '-1', type, source, accountID, isAttachmentOrReceipt, fileName, attachmentLink); + const route = ROUTES.ATTACHMENTS?.getRoute(report?.reportID, type, source, accountID, isAttachmentOrReceipt, fileName, attachmentLink); Navigation.navigate(route); }} onLongPress={(event) => { @@ -115,7 +115,7 @@ function ImageRenderer({tnode}: ImageRendererProps) { showContextMenuForReport( event, anchor, - report?.reportID ?? '-1', + report?.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs), diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx index 935503af653a..7de4802b3a0f 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx @@ -91,14 +91,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona if (isDisabled) { return; } - showContextMenuForReport( - event, - anchor, - report?.reportID ?? '-1', - action, - checkIfContextMenuActive, - ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs), - ); + showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs)); }} onPress={(event) => { event.preventDefault(); diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx index 8b1920b66ba0..1db7df36fb8c 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx @@ -43,14 +43,7 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d if (isDisabled) { return; } - showContextMenuForReport( - event, - anchor, - report?.reportID ?? '-1', - action, - checkIfContextMenuActive, - ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs), - ); + showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs)); }} shouldUseHapticsOnLongPress role={CONST.ROLE.PRESENTATION} diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 39e47d2d441a..4fea950ffce2 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -67,8 +67,8 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth const {shouldUseNarrowLayout, isSmallScreenWidth} = useResponsiveLayout(); const route = useRoute(); - const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport?.chatReportID ?? '-1'}`); - const [nextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${moneyRequestReport?.reportID ?? '-1'}`); + const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${moneyRequestReport?.chatReportID}`); + const [nextStep] = useOnyx(`${ONYXKEYS.COLLECTION.NEXT_STEP}${moneyRequestReport?.reportID}`); const [transactionThreadReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`); const [session] = useOnyx(ONYXKEYS.SESSION); const requestParentReportAction = useMemo(() => { @@ -83,7 +83,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const transaction = transactions?.[ `${ONYXKEYS.COLLECTION.TRANSACTION}${ - ReportActionsUtils.isMoneyRequestAction(requestParentReportAction) ? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID ?? -1 : -1 + ReportActionsUtils.isMoneyRequestAction(requestParentReportAction) && ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID }` ] ?? undefined; @@ -115,12 +115,12 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const hasScanningReceipt = ReportUtils.getTransactionsWithReceipts(moneyRequestReport?.reportID).some((t) => TransactionUtils.isReceiptBeingScanned(t)); const hasOnlyPendingTransactions = allTransactions.length > 0 && allTransactions.every((t) => TransactionUtils.isExpensifyCardTransaction(t) && TransactionUtils.isPending(t)); const transactionIDs = allTransactions.map((t) => t.transactionID); - const hasAllPendingRTERViolations = TransactionUtils.allHavePendingRTERViolation([transaction?.transactionID ?? '-1']); - const shouldShowBrokenConnectionViolation = TransactionUtils.shouldShowBrokenConnectionViolation(transaction?.transactionID ?? '-1', moneyRequestReport, policy); + const hasAllPendingRTERViolations = TransactionUtils.allHavePendingRTERViolation([transaction?.transactionID]); + const shouldShowBrokenConnectionViolation = TransactionUtils.shouldShowBrokenConnectionViolation(transaction?.transactionID, moneyRequestReport, policy); const hasOnlyHeldExpenses = ReportUtils.hasOnlyHeldExpenses(moneyRequestReport?.reportID ?? ''); const isPayAtEndExpense = TransactionUtils.isPayAtEndExpense(transaction); const isArchivedReport = ReportUtils.isArchivedReport(moneyRequestReport); - const [archiveReason] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport?.reportID ?? '-1'}`, {selector: ReportUtils.getArchiveReason}); + const [archiveReason] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport?.reportID}`, {selector: ReportUtils.getArchiveReason}); const getCanIOUBePaid = useCallback( (onlyShowPayElsewhere = false) => IOU.canIOUBePaid(moneyRequestReport, chatReport, policy, transaction ? [transaction] : undefined, onlyShowPayElsewhere), @@ -216,10 +216,10 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const deleteTransaction = useCallback(() => { if (requestParentReportAction) { const iouTransactionID = ReportActionsUtils.isMoneyRequestAction(requestParentReportAction) - ? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID ?? '-1' - : '-1'; + ? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID + : undefined; if (ReportActionsUtils.isTrackExpenseAction(requestParentReportAction)) { - navigateBackToAfterDelete.current = IOU.deleteTrackExpense(moneyRequestReport?.reportID ?? '-1', iouTransactionID, requestParentReportAction, true); + navigateBackToAfterDelete.current = IOU.deleteTrackExpense(moneyRequestReport?.reportID, iouTransactionID, requestParentReportAction, true); } else { navigateBackToAfterDelete.current = IOU.deleteMoneyRequest(iouTransactionID, requestParentReportAction, true); } @@ -233,10 +233,13 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea return; } const iouTransactionID = ReportActionsUtils.isMoneyRequestAction(requestParentReportAction) - ? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID ?? '-1' - : '-1'; - const reportID = transactionThreadReport?.reportID ?? '-1'; + ? ReportActionsUtils.getOriginalMessage(requestParentReportAction)?.IOUTransactionID + : undefined; + const reportID = transactionThreadReport?.reportID; + if (!iouTransactionID || !reportID) { + return; + } TransactionActions.markAsCash(iouTransactionID, reportID); }, [requestParentReportAction, transactionThreadReport?.reportID]); @@ -266,7 +269,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea icon: getStatusIcon(Expensicons.Hourglass), description: ( diff --git a/src/components/ShowContextMenuContext.ts b/src/components/ShowContextMenuContext.ts index 6fefa987fac3..16a4b57f1bf3 100644 --- a/src/components/ShowContextMenuContext.ts +++ b/src/components/ShowContextMenuContext.ts @@ -44,7 +44,7 @@ ShowContextMenuContext.displayName = 'ShowContextMenuContext'; function showContextMenuForReport( event: GestureResponderEvent | MouseEvent, anchor: ContextMenuAnchor, - reportID: string, + reportID: string | undefined, action: OnyxEntry, checkIfContextMenuActive: () => void, isArchivedRoom = false, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7ec35c0c8fc0..2afa396ff1cb 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -7396,7 +7396,7 @@ function canUserPerformWriteAction(report: OnyxEntry) { /** * Returns ID of the original report from which the given reportAction is first created. */ -function getOriginalReportID(reportID: string, reportAction: OnyxInputOrEntry): string | undefined { +function getOriginalReportID(reportID: string | undefined, reportAction: OnyxInputOrEntry): string | undefined { const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`]; const currentReportAction = reportAction?.reportActionID ? reportActions?.[reportAction.reportActionID] : undefined; const transactionThreadReportID = ReportActionsUtils.getOneTransactionThreadReportID(reportID, reportActions ?? ([] as ReportAction[])); diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index 528481dae237..d69952d35486 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -792,7 +792,7 @@ function shouldShowBrokenConnectionViolation(transactionID: string | undefined, /** * Check if there is pending rter violation in all transactionViolations with given transactionIDs. */ -function allHavePendingRTERViolation(transactionIds: string[]): boolean { +function allHavePendingRTERViolation(transactionIds: Array): boolean { const transactionsWithRTERViolations = transactionIds.map((transactionId) => { const transactionViolations = getTransactionViolations(transactionId, allTransactionViolations); return hasPendingRTERViolation(transactionViolations); From 1d6f146e535fa1230e89fb8da213e165eb0bbf16 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 6 Jan 2025 17:59:02 +0300 Subject: [PATCH 18/29] lint fix --- src/ROUTES.ts | 10 +++++----- src/components/BrokenConnectionDescription.tsx | 4 ++-- src/components/MoneyReportHeader.tsx | 13 ++++++------- src/components/ReportWelcomeText.tsx | 10 +++++----- src/libs/TransactionUtils/index.ts | 2 +- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 30d2b1908f2d..274c80c5b9ad 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -362,7 +362,7 @@ const ROUTES = { }, REPORT_WITH_ID_DETAILS: { route: 'r/:reportID/details', - getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/details`, backTo), + getRoute: (reportID: string | undefined, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/details`, backTo), }, REPORT_WITH_ID_DETAILS_EXPORT: { route: 'r/:reportID/details/export/:connectionName', @@ -398,7 +398,7 @@ const ROUTES = { }, REPORT_DESCRIPTION: { route: 'r/:reportID/description', - getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/description` as const, backTo), + getRoute: (reportID: string | undefined, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/description` as const, backTo), }, TASK_ASSIGNEE: { route: 'r/:reportID/assignee', @@ -896,7 +896,7 @@ const ROUTES = { }, WORKSPACE_PROFILE_DESCRIPTION: { route: 'settings/workspaces/:policyID/profile/description', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/description` as const, + getRoute: (policyID: string | undefined) => `settings/workspaces/${policyID}/profile/description` as const, }, WORKSPACE_PROFILE_SHARE: { route: 'settings/workspaces/:policyID/profile/share', @@ -1221,7 +1221,7 @@ const ROUTES = { }, WORKSPACE_COMPANY_CARDS: { route: 'settings/workspaces/:policyID/company-cards', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/company-cards` as const, + getRoute: (policyID: string | undefined) => `settings/workspaces/${policyID}/company-cards` as const, }, WORKSPACE_COMPANY_CARDS_ADD_NEW: { route: 'settings/workspaces/:policyID/company-cards/add-card-feed', @@ -1472,7 +1472,7 @@ const ROUTES = { TRANSACTION_DUPLICATE_REVIEW_PAGE: { route: 'r/:threadReportID/duplicates/review', - getRoute: (threadReportID: string, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review` as const, backTo), + getRoute: (threadReportID: string | undefined, backTo?: string) => getUrlWithBackToParam(`r/${threadReportID}/duplicates/review` as const, backTo), }, TRANSACTION_DUPLICATE_REVIEW_MERCHANT_PAGE: { route: 'r/:threadReportID/duplicates/review/merchant', diff --git a/src/components/BrokenConnectionDescription.tsx b/src/components/BrokenConnectionDescription.tsx index bfcec0ed0d82..a1b9bd62ffa2 100644 --- a/src/components/BrokenConnectionDescription.tsx +++ b/src/components/BrokenConnectionDescription.tsx @@ -40,13 +40,13 @@ function BrokenConnectionDescription({transactionID, policy, report}: BrokenConn return translate('violations.brokenConnection530Error'); } - if (isPolicyAdmin && !ReportUtils.isCurrentUserSubmitter(report?.reportID ?? '')) { + if (isPolicyAdmin && !ReportUtils.isCurrentUserSubmitter(report?.reportID)) { return ( <> {`${translate('violations.adminBrokenConnectionError')}`} Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policy?.id ?? '-1'))} + onPress={() => Navigation.navigate(ROUTES.WORKSPACE_COMPANY_CARDS.getRoute(policy?.id))} >{`${translate('workspace.common.companyCards')}`} . diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 4fea950ffce2..6c7a43758374 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -56,7 +56,7 @@ type MoneyReportHeaderProps = { /** The reportID of the transaction thread report associated with this current report, if any */ // eslint-disable-next-line react/no-unused-prop-types - transactionThreadReportID?: string | null; + transactionThreadReportID: string | undefined; /** Method to trigger when pressing close button of the header */ onBackButtonPress: () => void; @@ -96,7 +96,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const {reimbursableSpend} = ReportUtils.getMoneyRequestSpendBreakdown(moneyRequestReport); const isOnHold = TransactionUtils.isOnHold(transaction); const isDeletedParentAction = !!requestParentReportAction && ReportActionsUtils.isDeletedAction(requestParentReportAction); - const isDuplicate = TransactionUtils.isDuplicate(transaction?.transactionID ?? ''); + const isDuplicate = TransactionUtils.isDuplicate(transaction?.transactionID); // Only the requestor can delete the request, admins can only edit it. const isActionOwner = @@ -117,7 +117,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const transactionIDs = allTransactions.map((t) => t.transactionID); const hasAllPendingRTERViolations = TransactionUtils.allHavePendingRTERViolation([transaction?.transactionID]); const shouldShowBrokenConnectionViolation = TransactionUtils.shouldShowBrokenConnectionViolation(transaction?.transactionID, moneyRequestReport, policy); - const hasOnlyHeldExpenses = ReportUtils.hasOnlyHeldExpenses(moneyRequestReport?.reportID ?? ''); + const hasOnlyHeldExpenses = ReportUtils.hasOnlyHeldExpenses(moneyRequestReport?.reportID); const isPayAtEndExpense = TransactionUtils.isPayAtEndExpense(transaction); const isArchivedReport = ReportUtils.isArchivedReport(moneyRequestReport); const [archiveReason] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${moneyRequestReport?.reportID}`, {selector: ReportUtils.getArchiveReason}); @@ -131,8 +131,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea const onlyShowPayElsewhere = useMemo(() => !canIOUBePaid && getCanIOUBePaid(true), [canIOUBePaid, getCanIOUBePaid]); const shouldShowMarkAsCashButton = - hasAllPendingRTERViolations || - (shouldShowBrokenConnectionViolation && (!PolicyUtils.isPolicyAdmin(policy) || ReportUtils.isCurrentUserSubmitter(moneyRequestReport?.reportID ?? ''))); + hasAllPendingRTERViolations || (shouldShowBrokenConnectionViolation && (!PolicyUtils.isPolicyAdmin(policy) || ReportUtils.isCurrentUserSubmitter(moneyRequestReport?.reportID))); const shouldShowPayButton = canIOUBePaid || onlyShowPayElsewhere; @@ -358,7 +357,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea text={translate('iou.reviewDuplicates')} style={styles.p0} onPress={() => { - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(transactionThreadReportID ?? '', Navigation.getReportRHPActiveRoute())); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(transactionThreadReportID, Navigation.getReportRHPActiveRoute())); }} /> @@ -426,7 +425,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea text={translate('iou.reviewDuplicates')} style={[styles.flex1, styles.pr0]} onPress={() => { - Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(transactionThreadReportID ?? '', Navigation.getReportRHPActiveRoute())); + Navigation.navigate(ROUTES.TRANSACTION_DUPLICATE_REVIEW_PAGE.getRoute(transactionThreadReportID, Navigation.getReportRHPActiveRoute())); }} /> )} diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index f6a144d26a43..b3e6103dbdba 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -34,7 +34,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) { const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || -1}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`); const isArchivedRoom = ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs); const isChatRoom = ReportUtils.isChatRoom(report); const isSelfDM = ReportUtils.isSelfDM(report); @@ -110,7 +110,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) { if (!canEditPolicyDescription) { return; } - Navigation.navigate(ROUTES.WORKSPACE_PROFILE_DESCRIPTION.getRoute(policy?.id ?? '-1')); + Navigation.navigate(ROUTES.WORKSPACE_PROFILE_DESCRIPTION.getRoute(policy?.id)); }} style={[styles.renderHTML, canEditPolicyDescription ? styles.cursorPointer : styles.cursorText]} accessibilityLabel={translate('reportDescriptionPage.roomDescription')} @@ -135,7 +135,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) { return; } const activeRoute = Navigation.getActiveRoute(); - Navigation.navigate(ROUTES.REPORT_DESCRIPTION.getRoute(report?.reportID ?? '-1', activeRoute)); + Navigation.navigate(ROUTES.REPORT_DESCRIPTION.getRoute(report?.reportID, activeRoute)); }} style={[styles.renderHTML, canEditReportDescription ? styles.cursorPointer : styles.cursorText]} accessibilityLabel={translate('reportDescriptionPage.roomDescription')} @@ -164,10 +164,10 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) { onPress={() => { const activeRoute = Navigation.getActiveRoute(); if (canEditReportDescription) { - Navigation.navigate(ROUTES.REPORT_DESCRIPTION.getRoute(report?.reportID ?? '-1', activeRoute)); + Navigation.navigate(ROUTES.REPORT_DESCRIPTION.getRoute(report?.reportID, activeRoute)); return; } - Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID ?? '-1', activeRoute)); + Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID, activeRoute)); }} style={styles.renderHTML} accessibilityLabel={translate('reportDescriptionPage.roomDescription')} diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index d69952d35486..2e7794e2243b 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -891,7 +891,7 @@ function getRecentTransactions(transactions: Record, size = 2): * @param transactionID - the transaction to check * @param checkDismissed - whether to check if the violation has already been dismissed as well */ -function isDuplicate(transactionID: string, checkDismissed = false): boolean { +function isDuplicate(transactionID: string | undefined, checkDismissed = false): boolean { const hasDuplicatedViolation = !!allTransactionViolations?.[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`]?.some( (violation: TransactionViolation) => violation.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION, ); From b28ce3c21312f1a2a95552679160270236eb2a7d Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 6 Jan 2025 18:17:47 +0300 Subject: [PATCH 19/29] lint fix --- .../VideoPlayerThumbnail.tsx | 2 +- .../BottomTabBar.tsx | 2 +- .../DebugTabView.tsx | 2 +- src/libs/SidebarUtils.ts | 26 ++++++++++++------- src/libs/WorkspacesSettingsUtils.ts | 4 +-- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx b/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx index edf6693c172e..b484fc10e8cc 100644 --- a/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx +++ b/src/components/VideoPlayerPreview/VideoPlayerThumbnail.tsx @@ -60,7 +60,7 @@ function VideoPlayerThumbnail({thumbnailUrl, onPress, accessibilityLabel, isDele showContextMenuForReport( event, anchor, - report?.reportID ?? '-1', + report?.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs), diff --git a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx index 5647c31c6604..fd2cae007562 100644 --- a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx @@ -70,7 +70,7 @@ function BottomTabBar({selectedTab}: BottomTabBarProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); const {activeWorkspaceID} = useActiveWorkspace(); - const {currentReportID} = useCurrentReportID() ?? {currentReportID: null}; + const {currentReportID} = useCurrentReportID() ?? {}; const [user] = useOnyx(ONYXKEYS.USER); const [betas] = useOnyx(ONYXKEYS.BETAS); const [priorityMode] = useOnyx(ONYXKEYS.NVP_PRIORITY_MODE); diff --git a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/DebugTabView.tsx b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/DebugTabView.tsx index 354529941e0c..a59bd3d8e55d 100644 --- a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/DebugTabView.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/DebugTabView.tsx @@ -27,7 +27,7 @@ type DebugTabViewProps = { selectedTab?: string; chatTabBrickRoad: BrickRoad; activeWorkspaceID?: string; - currentReportID: string | null; + currentReportID: string | undefined; reports: OnyxCollection; betas: OnyxEntry; policies: OnyxCollection; diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index 6d8eac2248cd..bf54b3b3f647 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -100,7 +100,7 @@ function ensureSingleSpacing(text: string) { * @returns An array of reportIDs sorted in the proper order */ function getOrderedReportIDs( - currentReportId: string | null, + currentReportId: string | undefined, reports: OnyxCollection, betas: OnyxEntry, policies: OnyxCollection, @@ -123,7 +123,7 @@ function getOrderedReportIDs( if ((Object.values(CONST.REPORT.UNSUPPORTED_TYPE) as string[]).includes(report?.type ?? '')) { return; } - const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); + const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID, report?.parentReportActionID); const doesReportHaveViolations = ReportUtils.shouldDisplayViolationsRBRInLHN(report, transactionViolations); const isHidden = ReportUtils.isHiddenForCurrentUser(report); const isFocused = report.reportID === currentReportId; @@ -155,7 +155,7 @@ function getOrderedReportIDs( if ( ReportUtils.shouldReportBeInOptionList({ report, - currentReportId: currentReportId ?? '-1', + currentReportId, isInFocusMode, betas, policies: policies as OnyxCollection, @@ -200,13 +200,13 @@ function getOrderedReportIDs( }; const isPinned = report?.isPinned ?? false; - const reportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); + const reportAction = ReportActionsUtils.getReportAction(report?.parentReportID, report?.parentReportActionID); const reportNameValuePairs = ReportUtils.getReportNameValuePairs(report?.reportID); if (isPinned || ReportUtils.requiresAttentionFromCurrentUser(report, reportAction)) { pinnedAndGBRReports.push(miniReport); } else if (report?.hasErrorsOtherThanFailedReceipt) { errorReports.push(miniReport); - } else if (hasValidDraftComment(report?.reportID ?? '-1')) { + } else if (hasValidDraftComment(report?.reportID)) { draftReports.push(miniReport); } else if (ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs)) { archivedReports.push(miniReport); @@ -239,7 +239,7 @@ function getOrderedReportIDs( // Now that we have all the reports grouped and sorted, they must be flattened into an array and only return the reportID. // The order the arrays are concatenated in matters and will determine the order that the groups are displayed in the sidebar. - const LHNReports = [...pinnedAndGBRReports, ...errorReports, ...draftReports, ...nonArchivedReports, ...archivedReports].map((report) => report?.reportID ?? '-1'); + const LHNReports = [...pinnedAndGBRReports, ...errorReports, ...draftReports, ...nonArchivedReports, ...archivedReports].map((report) => report?.reportID).filter(Boolean) as string[]; Performance.markEnd(CONST.TIMING.GET_ORDERED_REPORT_IDS); return LHNReports; @@ -385,7 +385,7 @@ function getOptionData({ result.iouReportID = report.iouReportID; result.keyForList = String(report.reportID); result.hasOutstandingChildRequest = report.hasOutstandingChildRequest; - result.parentReportID = report.parentReportID ?? '-1'; + result.parentReportID = report.parentReportID; result.isWaitingOnBankAccount = report.isWaitingOnBankAccount; result.notificationPreference = ReportUtils.getReportNotificationPreference(report); result.isAllowedToComment = ReportUtils.canUserPerformWriteAction(report); @@ -518,7 +518,7 @@ function getOptionData({ } if (!hasMultipleParticipants) { - result.accountID = personalDetail?.accountID ?? -1; + result.accountID = personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID; result.login = personalDetail?.login ?? ''; result.phoneNumber = personalDetail?.phoneNumber ?? ''; } @@ -529,7 +529,15 @@ function getOptionData({ result.subtitle = subtitle; result.participantsList = participantPersonalDetailList; - result.icons = ReportUtils.getIcons(report, personalDetails, personalDetail?.avatar, personalDetail?.login, personalDetail?.accountID ?? -1, policy, invoiceReceiverPolicy); + result.icons = ReportUtils.getIcons( + report, + personalDetails, + personalDetail?.avatar, + personalDetail?.login, + personalDetail?.accountID ?? CONST.DEFAULT_NUMBER_ID, + policy, + invoiceReceiverPolicy, + ); result.displayNamesWithTooltips = displayNamesWithTooltips; if (status) { diff --git a/src/libs/WorkspacesSettingsUtils.ts b/src/libs/WorkspacesSettingsUtils.ts index 60dff1c97247..4e878f0924a8 100644 --- a/src/libs/WorkspacesSettingsUtils.ts +++ b/src/libs/WorkspacesSettingsUtils.ts @@ -140,7 +140,7 @@ function hasWorkspaceSettingsRBR(policy: Policy) { function getChatTabBrickRoadReport( policyID: string | undefined, - currentReportId: string | null, + currentReportId: string | undefined, reports: OnyxCollection, betas: OnyxEntry, policies: OnyxCollection, @@ -182,7 +182,7 @@ function getChatTabBrickRoadReport( function getChatTabBrickRoad( policyID: string | undefined, - currentReportId: string | null, + currentReportId: string | undefined, reports: OnyxCollection, betas: OnyxEntry, policies: OnyxCollection, From 33a9c1af46eff6a59992b4487a4f3c9d82f3c0d9 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 6 Jan 2025 18:21:49 +0300 Subject: [PATCH 20/29] minor fix --- src/hooks/useReportIDs.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useReportIDs.tsx b/src/hooks/useReportIDs.tsx index 878e83cf4d87..02e0b4371968 100644 --- a/src/hooks/useReportIDs.tsx +++ b/src/hooks/useReportIDs.tsx @@ -70,7 +70,7 @@ function ReportIDsContextProvider({ const getOrderedReportIDs = useCallback( (currentReportID?: string) => - SidebarUtils.getOrderedReportIDs(currentReportID ?? null, chatReports, betas, policies, priorityMode, transactionViolations, activeWorkspaceID, policyMemberAccountIDs), + SidebarUtils.getOrderedReportIDs(currentReportID, chatReports, betas, policies, priorityMode, transactionViolations, activeWorkspaceID, policyMemberAccountIDs), // we need reports draft in deps array to reload the list when a draft is added or removed // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps [chatReports, betas, policies, priorityMode, transactionViolations, activeWorkspaceID, policyMemberAccountIDs, draftAmount], From 2f69e3d689e0c234cf3f129d98efcad4abd68453 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 6 Jan 2025 18:50:30 +0300 Subject: [PATCH 21/29] lint fix --- src/hooks/useReportIDs.tsx | 6 +++--- src/libs/SidebarUtils.ts | 2 +- .../report/ContextMenu/BaseReportActionContextMenu.tsx | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/hooks/useReportIDs.tsx b/src/hooks/useReportIDs.tsx index 02e0b4371968..1f2b1db5b0a8 100644 --- a/src/hooks/useReportIDs.tsx +++ b/src/hooks/useReportIDs.tsx @@ -22,7 +22,7 @@ type ReportIDsContextProviderProps = { type ReportIDsContextValue = { orderedReportIDs: string[]; - currentReportID: string; + currentReportID: string | undefined; policyMemberAccountIDs: number[]; }; @@ -94,12 +94,12 @@ function ReportIDsContextProvider({ derivedCurrentReportID !== '-1' && orderedReportIDs.indexOf(derivedCurrentReportID) === -1 ) { - return {orderedReportIDs: getOrderedReportIDs(derivedCurrentReportID), currentReportID: derivedCurrentReportID ?? '-1', policyMemberAccountIDs}; + return {orderedReportIDs: getOrderedReportIDs(derivedCurrentReportID), currentReportID: derivedCurrentReportID, policyMemberAccountIDs}; } return { orderedReportIDs, - currentReportID: derivedCurrentReportID ?? '-1', + currentReportID: derivedCurrentReportID, policyMemberAccountIDs, }; }, [getOrderedReportIDs, orderedReportIDs, derivedCurrentReportID, policyMemberAccountIDs, shouldUseNarrowLayout]); diff --git a/src/libs/SidebarUtils.ts b/src/libs/SidebarUtils.ts index bf54b3b3f647..7aa598321c30 100644 --- a/src/libs/SidebarUtils.ts +++ b/src/libs/SidebarUtils.ts @@ -129,7 +129,7 @@ function getOrderedReportIDs( const isFocused = report.reportID === currentReportId; const hasErrorsOtherThanFailedReceipt = ReportUtils.hasReportErrorsOtherThanFailedReceipt(report, doesReportHaveViolations, transactionViolations); const isReportInAccessible = report?.errorFields?.notFound; - if (ReportUtils.isOneTransactionThread(report.reportID, report.parentReportID ?? '0', parentReportAction)) { + if (ReportUtils.isOneTransactionThread(report.reportID, report.parentReportID, parentReportAction)) { return; } if (hasErrorsOtherThanFailedReceipt && !isReportInAccessible) { diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index 33e1bf9085d1..ed51fa6ef92b 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -137,7 +137,7 @@ function BaseReportActionContextMenu({ const [user] = useOnyx(ONYXKEYS.USER); const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`); const policyID = report?.policyID; - const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID ?? '-1'); + const workspaceAccountID = PolicyUtils.getWorkspaceAccountID(policyID); const [cardList = {}] = useOnyx(ONYXKEYS.CARD_LIST); const [cardsList] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_CARDS_LIST}${workspaceAccountID}_${CONST.EXPENSIFY_CARD.BANK}`); @@ -154,10 +154,10 @@ function BaseReportActionContextMenu({ const [childReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportAction?.childReportID}`); const parentReportAction = ReportActionsUtils.getReportAction(childReport?.parentReportID ?? '', childReport?.parentReportActionID ?? ''); - const {reportActions: paginatedReportActions} = usePaginatedReportActions(childReport?.reportID ?? '-1'); + const {reportActions: paginatedReportActions} = usePaginatedReportActions(childReport?.reportID); const transactionThreadReportID = useMemo( - () => ReportActionsUtils.getOneTransactionThreadReportID(childReport?.reportID ?? '-1', paginatedReportActions ?? [], isOffline), + () => ReportActionsUtils.getOneTransactionThreadReportID(childReport?.reportID, paginatedReportActions ?? [], isOffline), [childReport?.reportID, paginatedReportActions, isOffline], ); @@ -177,7 +177,7 @@ function BaseReportActionContextMenu({ }, [parentReportAction, isMoneyRequestReport, isInvoiceReport, paginatedReportActions, transactionThreadReport?.parentReportActionID]); const moneyRequestAction = transactionThreadReportID ? requestParentReportAction : parentReportAction; - const [parentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${childReport?.parentReportID ?? '-1'}`); + const [parentReportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${childReport?.parentReportID}`); const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${childReport?.parentReportID}`); const isMoneyRequest = useMemo(() => ReportUtils.isMoneyRequest(childReport), [childReport]); @@ -306,7 +306,7 @@ function BaseReportActionContextMenu({ ) ? ReportActionsUtils.getOriginalMessage(reportAction) : undefined; - const cardID = cardIssuedActionOriginalMessage?.cardID ?? -1; + const cardID = cardIssuedActionOriginalMessage?.cardID ?? CONST.DEFAULT_NUMBER_ID; const isPolicyAdmin = PolicyUtils.isPolicyAdmin(PolicyUtils.getPolicy(policyID)); const card = isPolicyAdmin ? cardsList?.[cardID] : cardList[cardID]; From 0de9910dd29c1027dbe9ce15b86d14cb84c38fd5 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 6 Jan 2025 20:03:22 +0300 Subject: [PATCH 22/29] fix lint --- src/libs/ReportUtils.ts | 4 +-- src/libs/actions/TransactionEdit.ts | 18 ++++++++-- .../BaseReportActionContextMenu.tsx | 2 +- src/pages/home/report/ReportActionItem.tsx | 14 ++++---- .../withReportAndPrivateNotesOrNotFound.tsx | 2 +- .../iou/request/step/IOURequestStepAmount.tsx | 8 ++--- .../request/step/IOURequestStepDistance.tsx | 36 ++++++++++--------- .../step/IOURequestStepScan/index.native.tsx | 10 +++--- .../request/step/IOURequestStepScan/index.tsx | 10 +++--- .../Report/NotificationPreferencePage.tsx | 2 +- .../settings/Report/ReportSettingsPage.tsx | 2 +- src/pages/settings/Report/VisibilityPage.tsx | 2 +- 12 files changed, 63 insertions(+), 47 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index c32f84488791..8f89ed27554a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -8141,9 +8141,9 @@ function isAllowedToSubmitDraftExpenseReport(report: OnyxEntry): boolean /** * What missing payment method does this report action indicate, if any? */ -function getIndicatedMissingPaymentMethod(userWallet: OnyxEntry, reportId: string, reportAction: ReportAction): MissingPaymentMethod | undefined { +function getIndicatedMissingPaymentMethod(userWallet: OnyxEntry, reportId: string | undefined, reportAction: ReportAction): MissingPaymentMethod | undefined { const isSubmitterOfUnsettledReport = isCurrentUserSubmitter(reportId) && !isSettled(reportId); - if (!isSubmitterOfUnsettledReport || !ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { + if (!reportId || !isSubmitterOfUnsettledReport || !ReportActionsUtils.isReimbursementQueuedAction(reportAction)) { return undefined; } const paymentType = ReportActionsUtils.getOriginalMessage(reportAction)?.paymentType; diff --git a/src/libs/actions/TransactionEdit.ts b/src/libs/actions/TransactionEdit.ts index a76cb8f25b75..56cb49b4163c 100644 --- a/src/libs/actions/TransactionEdit.ts +++ b/src/libs/actions/TransactionEdit.ts @@ -28,11 +28,19 @@ function createBackupTransaction(transaction: OnyxEntry) { /** * Removes a transaction from Onyx that was only used temporary in the edit flow */ -function removeBackupTransaction(transactionID: string) { +function removeBackupTransaction(transactionID: string | undefined) { + if (!transactionID) { + return; + } + Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`, null); } -function restoreOriginalTransactionFromBackup(transactionID: string, isDraft: boolean) { +function restoreOriginalTransactionFromBackup(transactionID: string | undefined, isDraft: boolean) { + if (!transactionID) { + return; + } + connection = Onyx.connect({ key: `${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`, callback: (backupTransaction) => { @@ -58,7 +66,11 @@ function createDraftTransaction(transaction: OnyxEntry) { Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transaction.transactionID}`, newTransaction); } -function removeDraftTransaction(transactionID: string) { +function removeDraftTransaction(transactionID: string | undefined) { + if (!transactionID) { + return; + } + Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, null); } diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx index ed51fa6ef92b..739b357c50b6 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.tsx @@ -153,7 +153,7 @@ function BaseReportActionContextMenu({ const [download] = useOnyx(`${ONYXKEYS.COLLECTION.DOWNLOAD}${sourceID}`); const [childReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportAction?.childReportID}`); - const parentReportAction = ReportActionsUtils.getReportAction(childReport?.parentReportID ?? '', childReport?.parentReportActionID ?? ''); + const parentReportAction = ReportActionsUtils.getReportAction(childReport?.parentReportID, childReport?.parentReportActionID); const {reportActions: paginatedReportActions} = usePaginatedReportActions(childReport?.reportID); const transactionThreadReportID = useMemo( diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 314b1fa12001..e00641b183aa 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -15,34 +15,34 @@ import type {PureReportActionItemProps} from './PureReportActionItem'; import PureReportActionItem from './PureReportActionItem'; function ReportActionItem({action, report, ...props}: PureReportActionItemProps) { - const reportID = report?.reportID ?? ''; + const reportID = report?.reportID; // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const originalReportID = useMemo(() => ReportUtils.getOriginalReportID(reportID, action) || '-1', [reportID, action]); + const originalReportID = useMemo(() => ReportUtils.getOriginalReportID(reportID, action), [reportID, action]); const [draftMessage] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${originalReportID}`, { selector: (draftMessagesForReport) => { const matchingDraftMessage = draftMessagesForReport?.[action.reportActionID]; return typeof matchingDraftMessage === 'string' ? matchingDraftMessage : matchingDraftMessage?.message; }, }); - const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${ReportActionsUtils.getIOUReportIDFromReportActionPreview(action) ?? -1}`); + const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${ReportActionsUtils.getIOUReportIDFromReportActionPreview(action)}`); const [emojiReactions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${action.reportActionID}`); const [userWallet] = useOnyx(ONYXKEYS.USER_WALLET); const [linkedTransactionRouteError] = useOnyx( - `${ONYXKEYS.COLLECTION.TRANSACTION}${ReportActionsUtils.isMoneyRequestAction(action) ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID ?? -1 : -1}`, + `${ONYXKEYS.COLLECTION.TRANSACTION}${ReportActionsUtils.isMoneyRequestAction(action) && ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID}`, {selector: (transaction) => transaction?.errorFields?.route ?? null}, ); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- This is needed to prevent the app from crashing when the app is using imported state. - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || '-1'}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`); const [isUserValidated] = useOnyx(ONYXKEYS.USER, {selector: (user) => !!user?.validated}); // The app would crash due to subscribing to the entire report collection if parentReportID is an empty string. So we should have a fallback ID here. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || -1}`); + const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`); const personalDetails = usePersonalDetails(); const blockedFromConcierge = useBlockedFromConcierge(); const [userBillingFundID] = useOnyx(ONYXKEYS.NVP_BILLING_FUND_ID); const linkedReport = ReportUtils.isChatThread(report) ? parentReport : report; - const missingPaymentMethod = ReportUtils.getIndicatedMissingPaymentMethod(userWallet, linkedReport?.reportID ?? '-1', action); + const missingPaymentMethod = ReportUtils.getIndicatedMissingPaymentMethod(userWallet, linkedReport?.reportID, action); return ( (null); const isSaveButtonPressed = useRef(false); const iouRequestType = getRequestType(transaction); - const policyID = report?.policyID ?? '-1'; + const policyID = report?.policyID; const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); @@ -108,7 +108,7 @@ function IOURequestStepAmount({ if (isSaveButtonPressed.current) { return; } - TransactionEdit.removeDraftTransaction(transaction?.transactionID ?? '-1'); + TransactionEdit.removeDraftTransaction(transaction?.transactionID); }; // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, []); @@ -172,7 +172,7 @@ function IOURequestStepAmount({ if (report?.reportID && !ReportUtils.isArchivedReport(report, reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { - const participantAccountID = participant?.accountID ?? -1; + const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID; return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); const backendAmount = CurrencyUtils.convertToBackendAmount(Number.parseFloat(amount)); @@ -288,7 +288,7 @@ function IOURequestStepAmount({ amount={Math.abs(transactionAmount)} skipConfirmation={shouldSkipConfirmation ?? false} iouType={iouType} - policyID={policy?.id ?? '-1'} + policyID={policy?.id} bankAccountRoute={ReportUtils.getBankAccountRoute(report)} ref={(e) => (textInput.current = e)} shouldKeepUserInput={transaction?.shouldShowOriginalAmount} diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index 30c3fe7d84aa..7e4027f10382 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -66,7 +66,7 @@ function IOURequestStepDistance({ const {isOffline} = useNetwork(); const {translate} = useLocalize(); const [allReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`); const [transactionBackup] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_BACKUP}${transactionID}`); const policy = usePolicy(report?.policyID); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); @@ -122,7 +122,7 @@ function IOURequestStepDistance({ const isCreatingNewRequest = !(backTo || isEditing); const [recentWaypoints, {status: recentWaypointsStatus}] = useOnyx(ONYXKEYS.NVP_RECENT_WAYPOINTS); const iouRequestType = TransactionUtils.getRequestType(transaction); - const customUnitRateID = TransactionUtils.getRateID(transaction) ?? '-1'; + const customUnitRateID = TransactionUtils.getRateID(transaction); // Sets `amount` and `split` share data before moving to the next step to avoid briefly showing `0.00` as the split share for participants const setDistanceRequestData = useCallback( @@ -138,9 +138,10 @@ function IOURequestStepDistance({ const mileageRates = DistanceRequestUtils.getMileageRates(IOUpolicy); const defaultMileageRate = DistanceRequestUtils.getDefaultMileageRate(IOUpolicy); - const mileageRate: MileageRate = TransactionUtils.isCustomUnitRateIDForP2P(transaction) + const mileageRate: MileageRate | undefined = TransactionUtils.isCustomUnitRateIDForP2P(transaction) ? DistanceRequestUtils.getRateForP2P(policyCurrency, transaction) - : mileageRates?.[customUnitRateID] ?? defaultMileageRate; + : // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + (customUnitRateID && mileageRates?.[customUnitRateID]) || defaultMileageRate; const {unit, rate} = mileageRate ?? {}; const distance = TransactionUtils.getDistanceInMeters(transaction, unit); @@ -148,7 +149,7 @@ function IOURequestStepDistance({ const amount = DistanceRequestUtils.getDistanceRequestAmount(distance, unit ?? CONST.CUSTOM_UNITS.DISTANCE_UNIT_MILES, rate ?? 0); IOU.setMoneyRequestAmount(transactionID, amount, currency); - const participantAccountIDs: number[] | undefined = participants?.map((participant) => Number(participant.accountID ?? -1)); + const participantAccountIDs: number[] | undefined = participants?.map((participant) => Number(participant.accountID ?? CONST.DEFAULT_NUMBER_ID)); if (isSplitRequest && amount && currency && !isPolicyExpenseChat) { IOU.setSplitShares(transaction, amount, currency ?? '', participantAccountIDs ?? []); } @@ -225,10 +226,10 @@ function IOURequestStepDistance({ // If the user cancels out of the modal without without saving changes, then the original transaction // needs to be restored from the backup so that all changes are removed. if (transactionWasSaved.current) { - TransactionEdit.removeBackupTransaction(transaction?.transactionID ?? '-1'); + TransactionEdit.removeBackupTransaction(transaction?.transactionID); return; } - TransactionEdit.restoreOriginalTransactionFromBackup(transaction?.transactionID ?? '-1', IOUUtils.shouldUseTransactionDraft(action)); + TransactionEdit.restoreOriginalTransactionFromBackup(transaction?.transactionID, IOUUtils.shouldUseTransactionDraft(action)); // If the user opens IOURequestStepDistance in offline mode and then goes online, re-open the report to fill in missing fields from the transaction backup if (!transaction?.reportID) { @@ -300,7 +301,7 @@ function IOURequestStepDistance({ if (report?.reportID && !ReportUtils.isArchivedReport(report, reportNameValuePairs) && iouType !== CONST.IOU.TYPE.CREATE) { const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { - const participantAccountID = participant?.accountID ?? -1; + const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID; return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); setDistanceRequestData(participants); @@ -455,14 +456,17 @@ function IOURequestStepDistance({ navigateBack(); return; } - IOU.updateMoneyRequestDistance({ - transactionID: transaction?.transactionID ?? '-1', - transactionThreadReportID: report?.reportID ?? '-1', - waypoints, - ...(hasRouteChanged ? {routes: transaction?.routes} : {}), - policy, - transactionBackup, - }); + + if (transaction?.transactionID && report?.reportID) { + IOU.updateMoneyRequestDistance({ + transactionID: transaction?.transactionID, + transactionThreadReportID: report?.reportID, + waypoints, + ...(hasRouteChanged ? {routes: transaction?.routes} : {}), + policy, + transactionBackup, + }); + } transactionWasSaved.current = true; navigateBack(); return; diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index 320132f93cbf..4f354b5b8181 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -74,10 +74,10 @@ function IOURequestStepScan({ const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); const [fileResize, setFileResize] = useState(null); const [fileSource, setFileSource] = useState(''); - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`); const policy = usePolicy(report?.policyID); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); - const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID ?? -1}`); + const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`); const platform = getPlatform(true); const [mutedPlatforms = {}] = useOnyx(ONYXKEYS.NVP_MUTED_PLATFORMS); const isPlatformMuted = mutedPlatforms[platform]; @@ -296,7 +296,7 @@ function IOURequestStepScan({ // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { - const participantAccountID = participant?.accountID ?? -1; + const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID; return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); @@ -309,10 +309,10 @@ function IOURequestStepScan({ IOU.startSplitBill({ participants, currentUserLogin: currentUserPersonalDetails?.login ?? '', - currentUserAccountID: currentUserPersonalDetails?.accountID ?? -1, + currentUserAccountID: currentUserPersonalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID, comment: '', receipt, - existingSplitChatReportID: reportID ?? -1, + existingSplitChatReportID: reportID, billable: false, category: '', tag: '', diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 933f34c12ca8..1670b9e343d7 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -86,10 +86,10 @@ function IOURequestStepScan({ const [isQueriedPermissionState, setIsQueriedPermissionState] = useState(false); const getScreenshotTimeoutRef = useRef(null); - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`); const policy = usePolicy(report?.policyID); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); - const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID ?? -1}`); + const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID}`); const [isLoadingReceipt, setIsLoadingReceipt] = useState(false); const [videoConstraints, setVideoConstraints] = useState(); @@ -325,7 +325,7 @@ function IOURequestStepScan({ // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { - const participantAccountID = participant?.accountID ?? -1; + const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID; return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); @@ -338,10 +338,10 @@ function IOURequestStepScan({ IOU.startSplitBill({ participants, currentUserLogin: currentUserPersonalDetails?.login ?? '', - currentUserAccountID: currentUserPersonalDetails?.accountID ?? -1, + currentUserAccountID: currentUserPersonalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID, comment: '', receipt, - existingSplitChatReportID: reportID ?? -1, + existingSplitChatReportID: reportID, billable: false, category: '', tag: '', diff --git a/src/pages/settings/Report/NotificationPreferencePage.tsx b/src/pages/settings/Report/NotificationPreferencePage.tsx index a5aeed92d2cb..4e6cb3c8d355 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.tsx +++ b/src/pages/settings/Report/NotificationPreferencePage.tsx @@ -23,7 +23,7 @@ type NotificationPreferencePageProps = WithReportOrNotFoundProps & PlatformStack function NotificationPreferencePage({report}: NotificationPreferencePageProps) { const route = useRoute>(); const {translate} = useLocalize(); - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID || -1}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID}`); const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const currentNotificationPreference = ReportUtils.getReportNotificationPreference(report); const shouldDisableNotificationPreferences = diff --git a/src/pages/settings/Report/ReportSettingsPage.tsx b/src/pages/settings/Report/ReportSettingsPage.tsx index dbccf1ffb8cd..2e9f70da7261 100644 --- a/src/pages/settings/Report/ReportSettingsPage.tsx +++ b/src/pages/settings/Report/ReportSettingsPage.tsx @@ -25,7 +25,7 @@ type ReportSettingsPageProps = WithReportOrNotFoundProps & PlatformStackScreenPr function ReportSettingsPage({report, policies, route}: ReportSettingsPageProps) { const backTo = route.params.backTo; - const reportID = report?.reportID ?? '-1'; + const reportID = report?.reportID; const styles = useThemeStyles(); const {translate} = useLocalize(); const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`); diff --git a/src/pages/settings/Report/VisibilityPage.tsx b/src/pages/settings/Report/VisibilityPage.tsx index 9731efc095f9..b07e45a8a7f1 100644 --- a/src/pages/settings/Report/VisibilityPage.tsx +++ b/src/pages/settings/Report/VisibilityPage.tsx @@ -24,7 +24,7 @@ type VisibilityProps = WithReportOrNotFoundProps & PlatformStackScreenProps>(); const [showConfirmModal, setShowConfirmModal] = useState(false); - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || -1}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`); const shouldGoBackToDetailsPage = useRef(false); const shouldDisableVisibility = ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs); From 7ea58c74906bf0dcf2b65a10603b9decb7c7fc65 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 6 Jan 2025 20:07:31 +0300 Subject: [PATCH 23/29] lint fix --- src/pages/iou/request/step/IOURequestStepAmount.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepAmount.tsx b/src/pages/iou/request/step/IOURequestStepAmount.tsx index c9c94eb61b5a..4814cd184ddf 100644 --- a/src/pages/iou/request/step/IOURequestStepAmount.tsx +++ b/src/pages/iou/request/step/IOURequestStepAmount.tsx @@ -58,7 +58,7 @@ function IOURequestStepAmount({ const iouRequestType = getRequestType(transaction); const policyID = report?.policyID; - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`); const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); const [draftTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`); From 6f9093a47f2b0aae802a23866b345b496d8bfd48 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 6 Jan 2025 23:37:00 +0300 Subject: [PATCH 24/29] minor fix --- src/components/ReportWelcomeText.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index b3e6103dbdba..884f7f0abe7f 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -34,7 +34,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) { const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || -1}`); const isArchivedRoom = ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs); const isChatRoom = ReportUtils.isChatRoom(report); const isSelfDM = ReportUtils.isSelfDM(report); From 02e102a4fcd1e5cb5c187cf92ef906c11f817811 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 6 Jan 2025 23:48:15 +0300 Subject: [PATCH 25/29] lint fix --- src/components/ReportWelcomeText.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportWelcomeText.tsx b/src/components/ReportWelcomeText.tsx index 884f7f0abe7f..08f0d17172a1 100644 --- a/src/components/ReportWelcomeText.tsx +++ b/src/components/ReportWelcomeText.tsx @@ -34,7 +34,7 @@ function ReportWelcomeText({report, policy}: ReportWelcomeTextProps) { const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(report); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || -1}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || undefined}`); const isArchivedRoom = ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs); const isChatRoom = ReportUtils.isChatRoom(report); const isSelfDM = ReportUtils.isSelfDM(report); From 949f1694fea088fe837465e5eadc81eeb3271bc2 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 6 Jan 2025 23:54:32 +0300 Subject: [PATCH 26/29] minor fix --- src/pages/home/report/ReportActionItem.tsx | 4 ++-- src/pages/settings/Report/NotificationPreferencePage.tsx | 2 +- src/pages/settings/Report/VisibilityPage.tsx | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index e00641b183aa..4dde741879c5 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -32,12 +32,12 @@ function ReportActionItem({action, report, ...props}: PureReportActionItemProps) {selector: (transaction) => transaction?.errorFields?.route ?? null}, ); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- This is needed to prevent the app from crashing when the app is using imported state. - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || undefined}`); const [isUserValidated] = useOnyx(ONYXKEYS.USER, {selector: (user) => !!user?.validated}); // The app would crash due to subscribing to the entire report collection if parentReportID is an empty string. So we should have a fallback ID here. // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID}`); + const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || undefined}`); const personalDetails = usePersonalDetails(); const blockedFromConcierge = useBlockedFromConcierge(); const [userBillingFundID] = useOnyx(ONYXKEYS.NVP_BILLING_FUND_ID); diff --git a/src/pages/settings/Report/NotificationPreferencePage.tsx b/src/pages/settings/Report/NotificationPreferencePage.tsx index 4e6cb3c8d355..434505ad473e 100644 --- a/src/pages/settings/Report/NotificationPreferencePage.tsx +++ b/src/pages/settings/Report/NotificationPreferencePage.tsx @@ -23,7 +23,7 @@ type NotificationPreferencePageProps = WithReportOrNotFoundProps & PlatformStack function NotificationPreferencePage({report}: NotificationPreferencePageProps) { const route = useRoute>(); const {translate} = useLocalize(); - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID || undefined}`); const isMoneyRequestReport = ReportUtils.isMoneyRequestReport(report); const currentNotificationPreference = ReportUtils.getReportNotificationPreference(report); const shouldDisableNotificationPreferences = diff --git a/src/pages/settings/Report/VisibilityPage.tsx b/src/pages/settings/Report/VisibilityPage.tsx index b07e45a8a7f1..560b96383a57 100644 --- a/src/pages/settings/Report/VisibilityPage.tsx +++ b/src/pages/settings/Report/VisibilityPage.tsx @@ -24,7 +24,7 @@ type VisibilityProps = WithReportOrNotFoundProps & PlatformStackScreenProps>(); const [showConfirmModal, setShowConfirmModal] = useState(false); - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID || undefined}`); const shouldGoBackToDetailsPage = useRef(false); const shouldDisableVisibility = ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs); From 997781ac36465f41a00d23e1e5295cd8e5fa2f10 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 8 Jan 2025 16:58:46 +0300 Subject: [PATCH 27/29] minor fix --- .../HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx index 571ef94099d8..84de2a6c6e9b 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx @@ -97,7 +97,7 @@ function ImageRenderer({tnode}: ImageRendererProps) { {({anchor, report, reportNameValuePairs, action, checkIfContextMenuActive, isDisabled}) => ( - {({accountID, type, reportID}) => ( + {({reportID, accountID, type}) => ( { From c239018aade784121b1000a42320591e4f0c36c8 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 8 Jan 2025 17:21:58 +0300 Subject: [PATCH 28/29] fix getLastMessageTextForReport --- 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 4d1988a53bde..256ecf47c67c 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -509,7 +509,7 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails const lastOriginalReportAction = reportID ? lastReportActions[reportID] : undefined; let lastMessageTextFromReport = ''; - if (report?.private_isArchived) { + if (ReportUtils.isArchivedNonExpenseReport(report)) { const archiveReason = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing (ReportActionUtils.isClosedAction(lastOriginalReportAction) && ReportActionUtils.getOriginalMessage(lastOriginalReportAction)?.reason) || CONST.REPORT.ARCHIVE_REASON.DEFAULT; From 7b22d112d5554650a76c9a59150b5f4c1783c64f Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 13 Jan 2025 22:42:37 +0300 Subject: [PATCH 29/29] minor fix --- src/components/ReportActionItem/ReportPreview.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index 8511b94f74ff..0d312b5d1a40 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -57,7 +57,7 @@ import { hasWarningTypeViolations, isAllowedToApproveExpenseReport, isAllowedToSubmitDraftExpenseReport, - isArchivedRoomWithID, + isArchivedReport, isInvoiceReport as isInvoiceReportUtils, isInvoiceRoom as isInvoiceRoomReportUtils, isOpenExpenseReport as isOpenExpenseReportUtils, @@ -242,12 +242,12 @@ function ReportPreview({ formattedMerchant = null; } - const isArchivedReport = ReportUtils.isArchivedReport(iouReport); + const isArchived = isArchivedReport(iouReport); const currentUserAccountID = getCurrentUserAccountID(); const isAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; const shouldShowSubmitButton = isOpenExpenseReport && - !isArchivedReport && + !isArchived && reimbursableSpend !== 0 && !showRTERViolationMessage && !shouldShowBrokenConnectionViolation && @@ -432,10 +432,10 @@ function ReportPreview({ const getPendingMessageProps: () => PendingMessageProps = () => { if (isPayAtEndExpense) { - if (!isArchivedReport) { + if (!isArchived) { return {shouldShow: true, messageIcon: Expensicons.Hourglass, messageDescription: translate('iou.bookingPending')}; } - if (isArchivedReport && archiveReason === CONST.REPORT.ARCHIVE_REASON.BOOKING_END_DATE_HAS_PASSED) { + if (isArchived && archiveReason === CONST.REPORT.ARCHIVE_REASON.BOOKING_END_DATE_HAS_PASSED) { return { shouldShow: true, messageIcon: Expensicons.Box,