From 93a45ce889767c544fec534aa4a5b6adddf62a90 Mon Sep 17 00:00:00 2001 From: Jakub Butkiewicz Date: Mon, 27 May 2024 13:43:07 +0200 Subject: [PATCH 01/16] feat: default onyx ids to -1 --- src/components/AddPaymentMethodMenu.tsx | 2 +- src/components/AddPlaidBankAccount.tsx | 2 +- .../BaseAnchorForAttachmentsOnly.tsx | 2 +- src/components/ArchivedReportFooter.tsx | 6 +- src/components/AttachmentModal.tsx | 12 +- src/components/AvatarWithDisplayName.tsx | 4 +- .../HTMLRenderers/ImageRenderer.tsx | 4 +- .../HTMLRenderers/MentionUserRenderer.tsx | 2 +- .../HTMLRenderers/PreRenderer.tsx | 2 +- .../HTMLRenderers/VideoRenderer.tsx | 4 +- .../LHNOptionsList/LHNOptionsList.tsx | 6 +- .../LHNOptionsList/OptionRowLHN.tsx | 4 +- src/components/MoneyReportHeader.tsx | 8 +- .../MoneyRequestConfirmationList.tsx | 14 ++- src/components/MoneyRequestHeader.tsx | 16 +-- src/components/ParentNavigationSubtitle.tsx | 4 +- src/components/ProcessMoneyReportHoldMenu.tsx | 2 +- src/components/ReceiptImage.tsx | 2 +- .../ReportActionItem/MoneyReportView.tsx | 2 +- .../ReportActionItem/MoneyRequestAction.tsx | 4 +- .../MoneyRequestPreviewContent.tsx | 6 +- .../ReportActionItem/MoneyRequestView.tsx | 40 +++---- .../ReportActionItem/RenameAction.tsx | 4 +- .../ReportActionItemImage.tsx | 2 +- .../ReportActionItem/ReportPreview.tsx | 2 +- .../ReportActionItem/TaskPreview.tsx | 2 +- src/components/SettlementButton.tsx | 2 +- src/components/TaskHeaderActionButton.tsx | 2 +- .../VideoPlayerThumbnail.tsx | 2 +- src/components/WorkspaceSwitcherButton.tsx | 2 +- src/components/withCurrentReportID.tsx | 2 +- src/hooks/useCurrentUserPersonalDetails.ts | 2 +- src/hooks/useReportIDs.tsx | 4 +- src/libs/DistanceRequestUtils.ts | 4 +- src/libs/ModifiedExpenseMessage.ts | 2 +- .../linkingConfig/getAdaptedStateFromPath.ts | 2 +- src/libs/OptionsListUtils.ts | 24 ++-- src/libs/ReportActionComposeFocusManager.ts | 2 +- src/libs/ReportActionsUtils.ts | 6 +- src/libs/ReportUtils.ts | 78 ++++++------- src/libs/SidebarUtils.ts | 10 +- src/libs/TaskUtils.ts | 2 +- src/libs/TransactionUtils.ts | 4 +- src/libs/UnreadIndicatorUpdater/index.ts | 4 +- src/libs/actions/BankAccounts.ts | 2 +- src/libs/actions/IOU.ts | 106 +++++++++--------- src/libs/actions/Link.ts | 2 +- src/libs/actions/Policy.ts | 10 +- src/libs/actions/PriorityMode.ts | 2 +- src/libs/actions/Report.ts | 24 ++-- src/libs/actions/ReportActions.ts | 4 +- src/libs/actions/Task.ts | 28 ++--- src/libs/actions/TeachersUnite.ts | 2 +- src/pages/DetailsPage.tsx | 2 +- src/pages/EditReportFieldPage.tsx | 2 +- .../FeesAndTerms/substeps/TermsStep.tsx | 2 +- src/pages/EnablePayments/TermsStep.tsx | 2 +- src/pages/FlagCommentPage.tsx | 4 +- src/pages/GroupChatNameEditPage.tsx | 2 +- src/pages/InviteReportParticipantsPage.tsx | 4 +- src/pages/NewChatPage.tsx | 2 +- src/pages/ProfilePage.tsx | 6 +- .../BankInfo/BankInfo.tsx | 2 +- .../BankInfo/substeps/Confirmation.tsx | 2 +- .../BankInfo/substeps/Manual.tsx | 2 +- .../BankInfo/substeps/Plaid.tsx | 2 +- .../BeneficialOwnersStep.tsx | 4 +- .../BusinessInfo/BusinessInfo.tsx | 4 +- .../BusinessInfo/substeps/NameBusiness.tsx | 2 +- .../BusinessInfo/substeps/TaxIdBusiness.tsx | 4 +- .../CompleteVerification.tsx | 4 +- .../components/BankAccountValidationForm.tsx | 4 +- .../components/FinishChatCard.tsx | 2 +- .../PersonalInfo/PersonalInfo.tsx | 4 +- .../ReimbursementAccountPage.tsx | 2 +- .../RequestorOnfidoStep.tsx | 4 +- .../VerifyIdentity/VerifyIdentity.tsx | 4 +- src/pages/ReportAvatar.tsx | 6 +- src/pages/ReportDetailsPage.tsx | 30 ++--- src/pages/ReportParticipantDetailsPage.tsx | 2 +- .../ReportParticipantRoleSelectionPage.tsx | 4 +- src/pages/RoomMembersPage.tsx | 2 +- src/pages/ShareCodePage.tsx | 2 +- src/pages/TransactionReceiptPage.tsx | 12 +- src/pages/WorkspaceSwitcherPage/index.tsx | 2 +- src/pages/home/HeaderView.tsx | 4 +- src/pages/home/ReportScreen.tsx | 8 +- .../BaseReportActionContextMenu.tsx | 2 +- .../report/ContextMenu/ContextMenuActions.tsx | 12 +- .../PopoverReportActionContextMenu.tsx | 10 +- .../AttachmentPickerWithMenuItems.tsx | 10 +- .../ComposerWithSuggestions.tsx | 2 +- .../ReportActionCompose.tsx | 4 +- .../ReportActionCompose/SuggestionMention.tsx | 2 +- src/pages/home/report/ReportActionItem.tsx | 22 ++-- .../home/report/ReportActionItemMessage.tsx | 4 +- .../report/ReportActionItemParentAction.tsx | 6 +- .../home/report/ReportActionItemSingle.tsx | 8 +- src/pages/home/report/ReportActionsList.tsx | 2 +- src/pages/home/report/ReportActionsView.tsx | 10 +- src/pages/home/report/ReportFooter.tsx | 2 +- .../report/SystemChatReportFooterMessage.tsx | 4 +- src/pages/home/report/ThreadDivider.tsx | 6 +- .../withReportAndReportActionOrNotFound.tsx | 2 +- src/pages/home/sidebar/SidebarLinksData.tsx | 2 +- .../FloatingActionButtonAndPopover.tsx | 8 +- src/pages/iou/HoldReasonPage.tsx | 2 +- src/pages/iou/MoneyRequestAmountForm.tsx | 2 +- src/pages/iou/SplitBillDetailsPage.tsx | 4 +- src/pages/iou/request/IOURequestStartPage.tsx | 2 +- .../MoneyRequestParticipantsSelector.tsx | 2 +- .../iou/request/step/IOURequestStepAmount.tsx | 14 +-- .../request/step/IOURequestStepCategory.tsx | 8 +- .../step/IOURequestStepConfirmation.tsx | 4 +- .../request/step/IOURequestStepCurrency.tsx | 2 +- .../iou/request/step/IOURequestStepDate.tsx | 18 +-- .../step/IOURequestStepDescription.tsx | 16 +-- .../request/step/IOURequestStepDistance.tsx | 12 +- .../step/IOURequestStepDistanceRate.tsx | 8 +- .../request/step/IOURequestStepMerchant.tsx | 8 +- .../step/IOURequestStepParticipants.tsx | 4 +- .../step/IOURequestStepScan/index.native.tsx | 10 +- .../request/step/IOURequestStepScan/index.tsx | 10 +- .../request/step/IOURequestStepSplitPayer.tsx | 4 +- .../iou/request/step/IOURequestStepTag.tsx | 10 +- .../step/IOURequestStepTaxAmountPage.tsx | 8 +- .../step/IOURequestStepTaxRatePage.tsx | 10 +- .../step/withFullTransactionOrNotFound.tsx | 2 +- .../step/withWritableReportOrNotFound.tsx | 4 +- src/pages/settings/InitialSettingsPage.tsx | 2 +- .../Contacts/ContactMethodDetailsPage.tsx | 2 +- src/pages/settings/Profile/ProfileAvatar.tsx | 2 +- .../settings/Report/ReportSettingsPage.tsx | 2 +- src/pages/settings/Report/RoomNamePage.tsx | 4 +- .../settings/Report/WriteCapabilityPage.tsx | 2 +- .../Wallet/Card/BaseGetPhysicalCard.tsx | 4 +- .../settings/Wallet/TransferBalancePage.tsx | 4 +- .../settings/Wallet/WalletPage/WalletPage.tsx | 6 +- src/pages/tasks/NewTaskDetailsPage.tsx | 4 +- src/pages/tasks/NewTaskPage.tsx | 2 +- src/pages/tasks/TaskAssigneeSelectorModal.tsx | 2 +- .../workspace/AccessOrNotFoundWrapper.tsx | 2 +- src/pages/workspace/WorkspaceAvatar.tsx | 2 +- src/pages/workspace/WorkspaceInitialPage.tsx | 6 +- src/pages/workspace/WorkspaceInvitePage.tsx | 2 +- src/pages/workspace/WorkspaceJoinUserPage.tsx | 2 +- .../workspace/WorkspaceMoreFeaturesPage.tsx | 14 +-- src/pages/workspace/WorkspaceNamePage.tsx | 2 +- src/pages/workspace/WorkspaceNewRoomPage.tsx | 4 +- .../workspace/WorkspacePageWithSections.tsx | 4 +- .../WorkspaceProfileCurrencyPage.tsx | 4 +- .../WorkspaceProfileDescriptionPage.tsx | 2 +- src/pages/workspace/WorkspaceProfilePage.tsx | 24 ++-- .../workspace/WorkspaceProfileSharePage.tsx | 2 +- .../WorkspaceResetBankAccountModal.tsx | 2 +- src/pages/workspace/WorkspacesListPage.tsx | 4 +- .../accounting/PolicyAccountingPage.tsx | 4 +- .../advanced/QuickbooksAccountSelectPage.tsx | 2 +- .../qbo/advanced/QuickbooksAdvancedPage.tsx | 2 +- .../QuickbooksInvoiceAccountSelectPage.tsx | 2 +- ...uickbooksCompanyCardExpenseAccountPage.tsx | 2 +- ...ompanyCardExpenseAccountSelectCardPage.tsx | 2 +- ...oksCompanyCardExpenseAccountSelectPage.tsx | 2 +- .../QuickbooksExportConfigurationPage.tsx | 2 +- .../export/QuickbooksExportDateSelectPage.tsx | 2 +- ...ickbooksExportInvoiceAccountSelectPage.tsx | 2 +- ...NonReimbursableDefaultVendorSelectPage.tsx | 2 +- ...oksOutOfPocketExpenseAccountSelectPage.tsx | 2 +- ...oksOutOfPocketExpenseConfigurationPage.tsx | 2 +- ...ooksOutOfPocketExpenseEntitySelectPage.tsx | 2 +- ...ooksPreferredExporterConfigurationPage.tsx | 2 +- .../import/QuickbooksChartOfAccountsPage.tsx | 2 +- .../qbo/import/QuickbooksClassesPage.tsx | 2 +- .../qbo/import/QuickbooksCustomersPage.tsx | 2 +- .../qbo/import/QuickbooksImportPage.tsx | 2 +- .../qbo/import/QuickbooksLocationsPage.tsx | 2 +- .../qbo/import/QuickbooksTaxesPage.tsx | 2 +- .../accounting/xero/XeroImportPage.tsx | 2 +- .../XeroMapCostCentersToConfigurationPage.tsx | 2 +- .../XeroMapRegionsToConfigurationPage.tsx | 2 +- .../XeroOrganizationConfigurationPage.tsx | 2 +- .../xero/XeroTaxesConfigurationPage.tsx | 2 +- .../XeroTrackingCategoryConfigurationPage.tsx | 2 +- .../xero/advanced/XeroAdvancedPage.tsx | 6 +- .../XeroBillPaymentAccountSelectorPage.tsx | 2 +- .../XeroInvoiceAccountSelectorPage.tsx | 2 +- .../xero/export/XeroBankAccountSelectPage.tsx | 2 +- .../export/XeroExportConfigurationPage.tsx | 2 +- .../XeroPreferredExporterSelectPage.tsx | 2 +- .../export/XeroPurchaseBillDateSelectPage.tsx | 2 +- .../xero/import/XeroChartOfAccountsPage.tsx | 2 +- .../import/XeroCustomerConfigurationPage.tsx | 2 +- .../workspace/card/WorkspaceCardPage.tsx | 2 +- .../categories/WorkspaceCategoriesPage.tsx | 2 +- .../WorkspaceCategoriesSettingsPage.tsx | 4 +- .../members/WorkspaceOwnerChangeCheck.tsx | 2 +- .../members/WorkspaceOwnerChangeErrorPage.tsx | 2 +- .../WorkspaceOwnerChangeSuccessPage.tsx | 2 +- .../members/WorkspaceOwnerPaymentCardForm.tsx | 2 +- .../WorkspaceRateAndUnitPage/InitialPage.tsx | 12 +- .../WorkspaceRateAndUnitPage/RatePage.tsx | 6 +- .../WorkspaceRateAndUnitPage/UnitPage.tsx | 6 +- .../reimburse/WorkspaceReimburseSection.tsx | 4 +- .../reimburse/WorkspaceReimburseView.tsx | 8 +- .../workspace/tags/WorkspaceTagsPage.tsx | 2 +- .../workspace/tags/WorkspaceViewTagsPage.tsx | 2 +- src/pages/workspace/taxes/NamePage.tsx | 2 +- src/pages/workspace/taxes/ValuePage.tsx | 2 +- src/pages/workspace/withPolicy.tsx | 2 +- src/pages/workspace/withPolicyConnections.tsx | 2 +- .../WorkspaceAutoReportingFrequencyPage.tsx | 6 +- ...orkspaceAutoReportingMonthlyOffsetPage.tsx | 2 +- .../workflows/WorkspaceWorkflowsPage.tsx | 10 +- .../workflows/WorkspaceWorkflowsPayerPage.tsx | 2 +- tests/actions/IOUTest.ts | 30 ++--- tests/unit/MigrationTest.ts | 8 +- 216 files changed, 617 insertions(+), 613 deletions(-) diff --git a/src/components/AddPaymentMethodMenu.tsx b/src/components/AddPaymentMethodMenu.tsx index ac9657694500..734e8affa9ea 100644 --- a/src/components/AddPaymentMethodMenu.tsx +++ b/src/components/AddPaymentMethodMenu.tsx @@ -67,7 +67,7 @@ function AddPaymentMethodMenu({ // which then starts a bottom up flow and creates a Collect workspace where the payer is an admin and payee is an employee. const isIOUReport = ReportUtils.isIOUReport(iouReport ?? {}); const canUseBusinessBankAccount = - ReportUtils.isExpenseReport(iouReport ?? {}) || (isIOUReport && !ReportActionsUtils.hasRequestFromCurrentAccount(iouReport?.reportID ?? '', session?.accountID ?? 0)); + ReportUtils.isExpenseReport(iouReport ?? {}) || (isIOUReport && !ReportActionsUtils.hasRequestFromCurrentAccount(iouReport?.reportID ?? '-1', session?.accountID ?? -1)); const canUsePersonalBankAccount = shouldShowPersonalBankAccountOption || isIOUReport; diff --git a/src/components/AddPlaidBankAccount.tsx b/src/components/AddPlaidBankAccount.tsx index 366f14ec9780..8b91553c2fb9 100644 --- a/src/components/AddPlaidBankAccount.tsx +++ b/src/components/AddPlaidBankAccount.tsx @@ -93,7 +93,7 @@ function AddPlaidBankAccount({ const styles = useThemeStyles(); const plaidBankAccounts = plaidData?.bankAccounts ?? []; const defaultSelectedPlaidAccount = plaidBankAccounts.find((account) => account.plaidAccountID === selectedPlaidAccountID); - const defaultSelectedPlaidAccountID = defaultSelectedPlaidAccount?.plaidAccountID ?? ''; + const defaultSelectedPlaidAccountID = defaultSelectedPlaidAccount?.plaidAccountID ?? '-1'; const defaultSelectedPlaidAccountMask = plaidBankAccounts.find((account) => account.plaidAccountID === selectedPlaidAccountID)?.mask ?? ''; const subscribedKeyboardShortcuts = useRef void>>([]); const previousNetworkState = useRef(); diff --git a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx index 0c8af3dfc826..3e08586a9dd4 100644 --- a/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx +++ b/src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx @@ -52,7 +52,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', dow }} onPressIn={onPressIn} onPressOut={onPressOut} - onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} + onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} shouldUseHapticsOnLongPress accessibilityLabel={displayName} role={CONST.ROLE.BUTTON} diff --git a/src/components/ArchivedReportFooter.tsx b/src/components/ArchivedReportFooter.tsx index 9713e40136a2..07d309da6960 100644 --- a/src/components/ArchivedReportFooter.tsx +++ b/src/components/ArchivedReportFooter.tsx @@ -32,15 +32,15 @@ function ArchivedReportFooter({report, reportClosedAction, personalDetails = {}} const originalMessage = reportClosedAction?.actionName === CONST.REPORT.ACTIONS.TYPE.CLOSED ? reportClosedAction.originalMessage : null; const archiveReason = originalMessage?.reason ?? CONST.REPORT.ARCHIVE_REASON.DEFAULT; - const actorPersonalDetails = personalDetails?.[reportClosedAction?.actorAccountID ?? 0]; + const actorPersonalDetails = personalDetails?.[reportClosedAction?.actorAccountID ?? -1]; let displayName = PersonalDetailsUtils.getDisplayNameOrDefault(actorPersonalDetails); let oldDisplayName: string | undefined; if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED) { const newAccountID = originalMessage?.newAccountID; const oldAccountID = originalMessage?.oldAccountID; - displayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails?.[newAccountID ?? 0]); - oldDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails?.[oldAccountID ?? 0]); + displayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails?.[newAccountID ?? -1]); + oldDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails?.[oldAccountID ?? -1]); } const shouldRenderHTML = archiveReason !== CONST.REPORT.ARCHIVE_REASON.DEFAULT; diff --git a/src/components/AttachmentModal.tsx b/src/components/AttachmentModal.tsx index de98ba79d23c..c18445f307f3 100644 --- a/src/components/AttachmentModal.tsx +++ b/src/components/AttachmentModal.tsx @@ -271,9 +271,9 @@ function AttachmentModal({ * Detach the receipt and close the modal. */ const deleteAndCloseModal = useCallback(() => { - IOU.detachReceipt(transaction?.transactionID ?? ''); + IOU.detachReceipt(transaction?.transactionID ?? '-1'); setIsDeleteReceiptConfirmModalVisible(false); - Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID ?? '')); + Navigation.goBack(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(report?.reportID ?? '-1')); }, [transaction, report]); const isValidFile = useCallback((fileObject: FileObject) => { @@ -416,8 +416,8 @@ function AttachmentModal({ ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( CONST.IOU.ACTION.EDIT, iouType, - transaction?.transactionID ?? '', - report?.reportID ?? '', + transaction?.transactionID ?? '-1', + report?.reportID ?? '-1', Navigation.getActiveRouteWithoutParams(), ), ); @@ -603,8 +603,8 @@ AttachmentModal.displayName = 'AttachmentModal'; export default withOnyx({ transaction: { key: ({report}) => { - const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '', report?.parentReportActionID ?? ''); - const transactionID = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction?.originalMessage.IOUTransactionID ?? '0' : '0'; + const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '-1', report?.parentReportActionID ?? '-1'); + const transactionID = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction?.originalMessage.IOUTransactionID ?? '-1' : '-1'; return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`; }, }, diff --git a/src/components/AvatarWithDisplayName.tsx b/src/components/AvatarWithDisplayName.tsx index 156c27abbc9d..65ac67094f9b 100644 --- a/src/components/AvatarWithDisplayName.tsx +++ b/src/components/AvatarWithDisplayName.tsx @@ -70,7 +70,7 @@ function AvatarWithDisplayName({ const actorAccountID = useRef(null); useEffect(() => { - const parentReportAction = parentReportActions?.[report?.parentReportActionID ?? '']; + const parentReportAction = parentReportActions?.[report?.parentReportActionID ?? '-1']; actorAccountID.current = parentReportAction?.actorAccountID ?? -1; }, [parentReportActions, report]); @@ -179,7 +179,7 @@ AvatarWithDisplayName.displayName = 'AvatarWithDisplayName'; export default withOnyx({ parentReportActions: { - key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`, + key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '-1'}`, canEvict: false, }, personalDetails: { diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx index 79eaa30ee922..88ca61cb7a43 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/ImageRenderer.tsx @@ -81,10 +81,10 @@ function ImageRenderer({tnode}: ImageRendererProps) { { - const route = ROUTES.REPORT_ATTACHMENTS.getRoute(report?.reportID ?? '', source); + const route = ROUTES.REPORT_ATTACHMENTS.getRoute(report?.reportID ?? '-1', source); Navigation.navigate(route); }} - onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} + onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} shouldUseHapticsOnLongPress accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON} accessibilityLabel={translate('accessibilityHints.viewAttachment')} diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx index 504ddecb492b..4f1b8dd3f218 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx @@ -86,7 +86,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona {({anchor, report, action, checkIfContextMenuActive}) => ( showContextMenuForReport(event, anchor, report?.reportID ?? '', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} + onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} onPress={(event) => { event.preventDefault(); Navigation.navigate(navigationRoute); diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx index 39a1993c2334..4d1e58a42830 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/PreRenderer.tsx @@ -39,7 +39,7 @@ function PreRenderer({TDefaultRenderer, onPressIn, onPressOut, onLongPress, ...d onPress={onPressIn ?? (() => {})} onPressIn={onPressIn} onPressOut={onPressOut} - onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} + onLongPress={(event) => showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))} shouldUseHapticsOnLongPress role={CONST.ROLE.PRESENTATION} accessibilityLabel={translate('accessibilityHints.prestyledText')} diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx index 6802a4518ba1..17eb480e4c47 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/VideoRenderer.tsx @@ -29,13 +29,13 @@ function VideoRenderer({tnode, key}: VideoRendererProps) { { - const route = ROUTES.REPORT_ATTACHMENTS.getRoute(report?.reportID ?? '', sourceURL); + const route = ROUTES.REPORT_ATTACHMENTS.getRoute(report?.reportID ?? '-1', sourceURL); Navigation.navigate(route); }} /> diff --git a/src/components/LHNOptionsList/LHNOptionsList.tsx b/src/components/LHNOptionsList/LHNOptionsList.tsx index 8c43ae542932..7692071de217 100644 --- a/src/components/LHNOptionsList/LHNOptionsList.tsx +++ b/src/components/LHNOptionsList/LHNOptionsList.tsx @@ -109,9 +109,9 @@ function LHNOptionsList({ const itemFullReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`] ?? null; const itemReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`] ?? null; const itemParentReportActions = reportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${itemFullReport?.parentReportID}`] ?? null; - const itemParentReportAction = itemParentReportActions?.[itemFullReport?.parentReportActionID ?? ''] ?? null; + const itemParentReportAction = itemParentReportActions?.[itemFullReport?.parentReportActionID ?? '-1'] ?? null; const itemPolicy = policy?.[`${ONYXKEYS.COLLECTION.POLICY}${itemFullReport?.policyID}`] ?? null; - const transactionID = itemParentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? itemParentReportAction.originalMessage.IOUTransactionID ?? '' : ''; + const transactionID = itemParentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? itemParentReportAction.originalMessage.IOUTransactionID ?? '-1' : ''; const itemTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`] ?? null; const hasDraftComment = DraftCommentUtils.isValidDraftComment(draftComments?.[`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${reportID}`]); const sortedReportActions = ReportActionsUtils.getSortedReportActionsForDisplay(itemReportActions); @@ -121,7 +121,7 @@ function LHNOptionsList({ let lastReportActionTransactionID = ''; if (lastReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) { - lastReportActionTransactionID = lastReportAction.originalMessage?.IOUTransactionID ?? ''; + lastReportActionTransactionID = lastReportAction.originalMessage?.IOUTransactionID ?? '-1'; } const lastReportActionTransaction = transactions?.[`${ONYXKEYS.COLLECTION.TRANSACTION}${lastReportActionTransactionID}`] ?? {}; diff --git a/src/components/LHNOptionsList/OptionRowLHN.tsx b/src/components/LHNOptionsList/OptionRowLHN.tsx index b0418c9fdb28..fbb408197cc5 100644 --- a/src/components/LHNOptionsList/OptionRowLHN.tsx +++ b/src/components/LHNOptionsList/OptionRowLHN.tsx @@ -122,12 +122,12 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti const statusClearAfterDate = optionItem.status?.clearAfter ?? ''; const formattedDate = DateUtils.getStatusUntilDate(statusClearAfterDate); const statusContent = formattedDate ? `${statusText ? `${statusText} ` : ''}(${formattedDate})` : statusText; - const report = ReportUtils.getReport(optionItem.reportID ?? ''); + const report = ReportUtils.getReport(optionItem.reportID ?? '-1'); const isStatusVisible = !!emojiCode && ReportUtils.isOneOnOneChat(!isEmptyObject(report) ? report : null); const isGroupChat = ReportUtils.isGroupChat(optionItem) || ReportUtils.isDeprecatedGroupDM(optionItem); - const fullTitle = isGroupChat ? ReportUtils.getGroupChatName(undefined, false, optionItem.reportID ?? '') : optionItem.text; + const fullTitle = isGroupChat ? ReportUtils.getGroupChatName(undefined, false, optionItem.reportID ?? '-1') : optionItem.text; const subscriptAvatarBorderColor = isFocused ? focusedBackgroundColor : theme.sidebar; return ( { if (requestParentReportAction) { - const iouTransactionID = requestParentReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? requestParentReportAction.originalMessage?.IOUTransactionID ?? '' : ''; + const iouTransactionID = requestParentReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? requestParentReportAction.originalMessage?.IOUTransactionID ?? '-1' : '-1'; if (ReportActionsUtils.isTrackExpenseAction(requestParentReportAction)) { - IOU.deleteTrackExpense(moneyRequestReport?.reportID ?? '', iouTransactionID, requestParentReportAction, true); + IOU.deleteTrackExpense(moneyRequestReport?.reportID ?? '-1', iouTransactionID, requestParentReportAction, true); return; } IOU.deleteMoneyRequest(iouTransactionID, requestParentReportAction, true); @@ -175,8 +175,8 @@ function MoneyReportHeader({ if (!requestParentReportAction) { return; } - const iouTransactionID = requestParentReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? requestParentReportAction.originalMessage?.IOUTransactionID ?? '' : ''; - const reportID = transactionThreadReport?.reportID ?? ''; + const iouTransactionID = requestParentReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? requestParentReportAction.originalMessage?.IOUTransactionID ?? '-1' : '-1'; + const reportID = transactionThreadReport?.reportID ?? '-1'; TransactionActions.markAsCash(iouTransactionID, reportID); }, [requestParentReportAction, transactionThreadReport?.reportID]); diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index bb7e3ac4f78e..e30117b9525d 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -241,15 +241,15 @@ function MoneyRequestConfirmationList({ const isTypeInvoice = iouType === CONST.IOU.TYPE.INVOICE; const isScanRequest = useMemo(() => TransactionUtils.isScanRequest(transaction), [transaction]); - const transactionID = transaction?.transactionID ?? ''; - const customUnitRateID = TransactionUtils.getRateID(transaction) ?? ''; + const transactionID = transaction?.transactionID ?? '-1'; + const customUnitRateID = TransactionUtils.getRateID(transaction) ?? '-1'; useEffect(() => { if (customUnitRateID || !canUseP2PDistanceRequests) { return; } if (!customUnitRateID) { - const rateID = lastSelectedDistanceRates?.[policy?.id ?? ''] ?? defaultMileageRate?.customUnitRateID ?? ''; + const rateID = lastSelectedDistanceRates?.[policy?.id ?? '-1'] ?? defaultMileageRate?.customUnitRateID ?? '-1'; IOU.setCustomUnitRateID(transactionID, rateID); } }, [defaultMileageRate, customUnitRateID, lastSelectedDistanceRates, policy?.id, canUseP2PDistanceRequests, transactionID]); @@ -497,7 +497,7 @@ function MoneyRequestConfirmationList({ isSelected: false, rightElement: ( onSplitShareChange(participantOption.accountID ?? 0, Number(value))} + onAmountChange={(value: string) => onSplitShareChange(participantOption.accountID ?? -1, Number(value))} maxLength={formattedTotalAmount.length} /> ), @@ -1144,7 +1144,9 @@ function MoneyRequestConfirmationList({ isLabelHoverable={false} interactive={!isReadOnly && canUpdateSenderWorkspace} onPress={() => { - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_SEND_FROM.getRoute(iouType, transaction?.transactionID ?? '', reportID, Navigation.getActiveRouteWithoutParams())); + Navigation.navigate( + ROUTES.MONEY_REQUEST_STEP_SEND_FROM.getRoute(iouType, transaction?.transactionID ?? '-1', reportID, Navigation.getActiveRouteWithoutParams()), + ); }} style={styles.moneyRequestMenuItem} labelStyle={styles.mt2} diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index 13e8eb7be432..3747ca01822f 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -96,14 +96,14 @@ function MoneyRequestHeader({ const isActionOwner = typeof parentReportAction?.actorAccountID === 'number' && typeof session?.accountID === 'number' && parentReportAction.actorAccountID === session?.accountID; const isPolicyAdmin = policy?.role === CONST.POLICY.ROLE.ADMIN; const isApprover = ReportUtils.isMoneyRequestReport(moneyRequestReport) && moneyRequestReport?.managerID !== null && session?.accountID === moneyRequestReport?.managerID; - const hasAllPendingRTERViolations = TransactionUtils.allHavePendingRTERViolation([transaction?.transactionID ?? '']); + const hasAllPendingRTERViolations = TransactionUtils.allHavePendingRTERViolation([transaction?.transactionID ?? '-1']); const shouldShowMarkAsCashButton = isDraft && hasAllPendingRTERViolations; const deleteTransaction = useCallback(() => { if (parentReportAction) { - const iouTransactionID = parentReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction.originalMessage?.IOUTransactionID ?? '' : ''; + const iouTransactionID = parentReportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction.originalMessage?.IOUTransactionID ?? '-1' : ''; if (ReportActionsUtils.isTrackExpenseAction(parentReportAction)) { - IOU.deleteTrackExpense(parentReport?.reportID ?? '', iouTransactionID, parentReportAction, true); + IOU.deleteTrackExpense(parentReport?.reportID ?? '-1', iouTransactionID, parentReportAction, true); return; } IOU.deleteMoneyRequest(iouTransactionID, parentReportAction, true); @@ -113,7 +113,7 @@ function MoneyRequestHeader({ }, [parentReport?.reportID, parentReportAction, setIsDeleteModalVisible]); const markAsCash = useCallback(() => { - TransactionActions.markAsCash(transaction?.transactionID ?? '', report.reportID); + TransactionActions.markAsCash(transaction?.transactionID ?? '-1', report.reportID); }, [report.reportID, transaction?.transactionID]); const isScanning = TransactionUtils.hasReceipt(transaction) && TransactionUtils.isReceiptBeingScanned(transaction); @@ -125,7 +125,7 @@ function MoneyRequestHeader({ const canDeleteRequest = isActionOwner && (ReportUtils.canAddOrDeleteTransactions(moneyRequestReport) || ReportUtils.isTrackExpenseReport(report)) && !isDeletedParentAction; const changeMoneyRequestStatus = () => { - const iouTransactionID = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction.originalMessage?.IOUTransactionID ?? '' : ''; + const iouTransactionID = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction.originalMessage?.IOUTransactionID ?? '-1' : '-1'; if (isOnHold) { IOU.unholdRequest(iouTransactionID, report?.reportID); @@ -152,7 +152,7 @@ function MoneyRequestHeader({ if (TransactionUtils.isExpensifyCardTransaction(transaction) && TransactionUtils.isPending(transaction)) { return {title: getStatusIcon(Expensicons.CreditCardHourglass), description: translate('iou.transactionPendingDescription'), shouldShowBorderBottom: true}; } - if (TransactionUtils.hasPendingRTERViolation(TransactionUtils.getTransactionViolations(transaction?.transactionID ?? '', transactionViolations))) { + if (TransactionUtils.hasPendingRTERViolation(TransactionUtils.getTransactionViolations(transaction?.transactionID ?? '-1', transactionViolations))) { return { title: getStatusIcon(Expensicons.Hourglass), description: translate('iou.pendingMatchWithCreditCardDescription'), @@ -302,7 +302,7 @@ const MoneyRequestHeaderWithTransaction = withOnyx { const parentReportAction = (report.parentReportActionID && parentReportActions ? parentReportActions[report.parentReportActionID] : {}) as ReportAction & OriginalMessageIOU; - return `${ONYXKEYS.COLLECTION.TRANSACTION}${parentReportAction?.originalMessage?.IOUTransactionID ?? 0}`; + return `${ONYXKEYS.COLLECTION.TRANSACTION}${parentReportAction?.originalMessage?.IOUTransactionID ?? -1}`; }, }, shownHoldUseExplanation: { @@ -325,7 +325,7 @@ export default withOnyx< key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`, }, parentReportActions: { - key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID ?? '0'}`, + key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.parentReportID ?? '-1'}`, canEvict: false, }, })(MoneyRequestHeaderWithTransaction); diff --git a/src/components/ParentNavigationSubtitle.tsx b/src/components/ParentNavigationSubtitle.tsx index fc21d3d8b780..6437cec11a36 100644 --- a/src/components/ParentNavigationSubtitle.tsx +++ b/src/components/ParentNavigationSubtitle.tsx @@ -38,8 +38,8 @@ function ParentNavigationSubtitle({parentNavigationSubtitleData, parentReportAct return ( { - const parentAction = ReportActionsUtils.getReportAction(parentReportID, parentReportActionID ?? ''); - const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(parentAction, parentAction?.reportActionID ?? ''); + const parentAction = ReportActionsUtils.getReportAction(parentReportID, parentReportActionID ?? '-1'); + const isVisibleAction = ReportActionsUtils.shouldReportActionBeVisible(parentAction, parentAction?.reportActionID ?? '-1'); // Pop the thread report screen before navigating to the chat report. Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(parentReportID)); if (isVisibleAction && !isOffline) { diff --git a/src/components/ProcessMoneyReportHoldMenu.tsx b/src/components/ProcessMoneyReportHoldMenu.tsx index 6e81c9d57bc8..c485ece51a7c 100644 --- a/src/components/ProcessMoneyReportHoldMenu.tsx +++ b/src/components/ProcessMoneyReportHoldMenu.tsx @@ -55,7 +55,7 @@ function ProcessMoneyReportHoldMenu({ const onSubmit = (full: boolean) => { if (isApprove) { IOU.approveMoneyRequest(moneyRequestReport, full); - if (!full && isLinkedTransactionHeld(Navigation.getTopmostReportActionId() ?? '', moneyRequestReport.reportID)) { + if (!full && isLinkedTransactionHeld(Navigation.getTopmostReportActionId() ?? '-1', moneyRequestReport.reportID)) { Navigation.goBack(ROUTES.REPORT_WITH_ID.getRoute(moneyRequestReport.reportID)); } } else if (chatReport && paymentType) { diff --git a/src/components/ReceiptImage.tsx b/src/components/ReceiptImage.tsx index f113469b56f0..b572ea0a9cae 100644 --- a/src/components/ReceiptImage.tsx +++ b/src/components/ReceiptImage.tsx @@ -106,7 +106,7 @@ function ReceiptImage({ return ( Navigation.navigate(ROUTES.EDIT_REPORT_FIELD_REQUEST.getRoute(report.reportID, report.policyID ?? '', reportField.fieldID))} + onPress={() => Navigation.navigate(ROUTES.EDIT_REPORT_FIELD_REQUEST.getRoute(report.reportID, report.policyID ?? '-1', reportField.fieldID))} shouldShowRightIcon disabled={isFieldDisabled} wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]} diff --git a/src/components/ReportActionItem/MoneyRequestAction.tsx b/src/components/ReportActionItem/MoneyRequestAction.tsx index 4f91b2084b45..aee02c7fe256 100644 --- a/src/components/ReportActionItem/MoneyRequestAction.tsx +++ b/src/components/ReportActionItem/MoneyRequestAction.tsx @@ -86,12 +86,12 @@ function MoneyRequestAction({ const onMoneyRequestPreviewPressed = () => { if (isSplitBillAction) { - const reportActionID = action.reportActionID ?? '0'; + const reportActionID = action.reportActionID ?? '-1'; Navigation.navigate(ROUTES.SPLIT_BILL_DETAILS.getRoute(chatReportID, reportActionID)); return; } - const childReportID = action?.childReportID ?? '0'; + const childReportID = action?.childReportID ?? '-1'; Report.openReport(childReportID); Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(childReportID)); }; diff --git a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx index 4ff318bc3c47..5f9ca55e0ff3 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx @@ -87,8 +87,8 @@ function MoneyRequestPreviewContent({ const isOnHold = TransactionUtils.isOnHold(transaction); const isSettlementOrApprovalPartial = Boolean(iouReport?.pendingFields?.partial); const isPartialHold = isSettlementOrApprovalPartial && isOnHold; - const hasViolations = TransactionUtils.hasViolation(transaction?.transactionID ?? '', transactionViolations); - const hasNoticeTypeViolations = TransactionUtils.hasNoticeTypeViolation(transaction?.transactionID ?? '', transactionViolations); + const hasViolations = TransactionUtils.hasViolation(transaction?.transactionID ?? '-1', transactionViolations); + const hasNoticeTypeViolations = TransactionUtils.hasNoticeTypeViolation(transaction?.transactionID ?? '-1', transactionViolations); const hasFieldErrors = TransactionUtils.hasMissingSmartscanFields(transaction); const isDistanceRequest = TransactionUtils.isDistanceRequest(transaction); const isFetchingWaypointsFromServer = TransactionUtils.isFetchingWaypointsFromServer(transaction); @@ -190,7 +190,7 @@ function MoneyRequestPreviewContent({ if (TransactionUtils.isPending(transaction)) { return {shouldShow: true, messageIcon: Expensicons.CreditCardHourglass, messageDescription: translate('iou.transactionPending')}; } - if (TransactionUtils.hasPendingUI(transaction, TransactionUtils.getTransactionViolations(transaction?.transactionID ?? '', transactionViolations))) { + if (TransactionUtils.hasPendingUI(transaction, TransactionUtils.getTransactionViolations(transaction?.transactionID ?? '-1', transactionViolations))) { return {shouldShow: true, messageIcon: Expensicons.Hourglass, messageDescription: translate('iou.pendingMatchWithCreditCard')}; } return {shouldShow: false}; diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 37836580b740..1008d08aa2ff 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -101,7 +101,7 @@ function MoneyRequestView({ const {isOffline} = useNetwork(); const {isSmallScreenWidth} = useWindowDimensions(); const {translate, toLocaleDigit} = useLocalize(); - const parentReportAction = parentReportActions?.[report.parentReportActionID ?? ''] ?? null; + const parentReportAction = parentReportActions?.[report.parentReportActionID ?? '-1'] ?? null; const isTrackExpense = ReportUtils.isTrackExpenseReport(report); const {canUseViolations, canUseP2PDistanceRequests} = usePermissions(isTrackExpense ? CONST.IOU.TYPE.TRACK : undefined); const moneyRequestReport = parentReport; @@ -182,7 +182,7 @@ function MoneyRequestView({ let amountDescription = `${translate('iou.amount')}`; const hasRoute = TransactionUtils.hasRoute(transaction, isDistanceRequest); - const rateID = transaction?.comment.customUnit?.customUnitRateID ?? '0'; + const rateID = transaction?.comment.customUnit?.customUnitRateID ?? '-1'; const currency = policy ? policy.outputCurrency : PolicyUtils.getPersonalPolicy()?.outputCurrency ?? CONST.CURRENCY.USD; @@ -206,7 +206,7 @@ function MoneyRequestView({ Navigation.dismissModal(); return; } - IOU.updateMoneyRequestBillable(transaction?.transactionID ?? '', report?.reportID, newBillable, policy, policyTagList, policyCategories); + IOU.updateMoneyRequestBillable(transaction?.transactionID ?? '-1', report?.reportID, newBillable, policy, policyTagList, policyCategories); Navigation.dismissModal(); }, [transaction, report, policy, policyTagList, policyCategories], @@ -287,7 +287,7 @@ function MoneyRequestView({ interactive={canEditDistance} shouldShowRightIcon={canEditDistance} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID))} + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report.reportID))} /> {/* TODO: correct the pending field action https://github.com/Expensify/App/issues/36987 */} @@ -312,7 +312,7 @@ function MoneyRequestView({ interactive={canEditDistance} shouldShowRightIcon={canEditDistance} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID))} + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DISTANCE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report.reportID))} /> ); @@ -374,7 +374,7 @@ function MoneyRequestView({ ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute( CONST.IOU.ACTION.EDIT, iouType, - transaction?.transactionID ?? '', + transaction?.transactionID ?? '-1', report.reportID, Navigation.getActiveRouteWithoutParams(), ), @@ -394,7 +394,7 @@ function MoneyRequestView({ titleStyle={styles.textHeadlineH2} interactive={canEditAmount} shouldShowRightIcon={canEditAmount} - onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID))} + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report.reportID))} brickRoadIndicator={getErrorForField('amount') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('amount')} /> @@ -407,7 +407,9 @@ function MoneyRequestView({ interactive={canEdit} shouldShowRightIcon={canEdit} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID))} + onPress={() => + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report.reportID)) + } wrapperStyle={[styles.pv2, styles.taskDescriptionMenuItem]} brickRoadIndicator={getErrorForField('comment') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('comment')} @@ -425,7 +427,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEditMerchant} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report.reportID)) } wrapperStyle={[styles.taskDescriptionMenuItem]} brickRoadIndicator={getErrorForField('merchant') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} @@ -441,7 +443,7 @@ function MoneyRequestView({ interactive={canEditDate} shouldShowRightIcon={canEditDate} titleStyle={styles.flex1} - onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID))} + onPress={() => Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report.reportID))} brickRoadIndicator={getErrorForField('date') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('date')} /> @@ -455,7 +457,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEdit} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_CATEGORY.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report.reportID)) } brickRoadIndicator={getErrorForField('category') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('category')} @@ -476,7 +478,7 @@ function MoneyRequestView({ titleStyle={styles.flex1} onPress={() => Navigation.navigate( - ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.EDIT, iouType, orderWeight, transaction?.transactionID ?? '', report.reportID), + ROUTES.MONEY_REQUEST_STEP_TAG.getRoute(CONST.IOU.ACTION.EDIT, iouType, orderWeight, transaction?.transactionID ?? '-1', report.reportID), ) } brickRoadIndicator={ @@ -510,7 +512,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEdit} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_RATE.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report.reportID)) } brickRoadIndicator={getErrorForField('tax') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} errorText={getErrorForField('tax')} @@ -527,7 +529,7 @@ function MoneyRequestView({ shouldShowRightIcon={canEdit} titleStyle={styles.flex1} onPress={() => - Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '', report.reportID)) + Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_TAX_AMOUNT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction?.transactionID ?? '-1', report.reportID)) } /> @@ -574,7 +576,7 @@ export default withOnyx `${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`, }, parentReportActions: { - key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`, + key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '-1'}`, canEvict: false, }, distanceRates: { @@ -585,17 +587,17 @@ export default withOnyx({ transaction: { key: ({report, parentReportActions}) => { - const parentReportAction = parentReportActions?.[report.parentReportActionID ?? '']; + const parentReportAction = parentReportActions?.[report.parentReportActionID ?? '-1']; const originalMessage = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction.originalMessage : undefined; - const transactionID = originalMessage?.IOUTransactionID ?? 0; + const transactionID = originalMessage?.IOUTransactionID ?? -1; return `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`; }, }, transactionViolations: { key: ({report, parentReportActions}) => { - const parentReportAction = parentReportActions?.[report.parentReportActionID ?? '']; + const parentReportAction = parentReportActions?.[report.parentReportActionID ?? '-1']; const originalMessage = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction.originalMessage : undefined; - const transactionID = originalMessage?.IOUTransactionID ?? 0; + const transactionID = originalMessage?.IOUTransactionID ?? -1; return `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`; }, }, diff --git a/src/components/ReportActionItem/RenameAction.tsx b/src/components/ReportActionItem/RenameAction.tsx index b4b2553d652a..f2a3fead2336 100644 --- a/src/components/ReportActionItem/RenameAction.tsx +++ b/src/components/ReportActionItem/RenameAction.tsx @@ -16,9 +16,9 @@ function RenameAction({currentUserPersonalDetails, action}: RenameActionProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const currentUserAccountID = currentUserPersonalDetails.accountID ?? ''; + const currentUserAccountID = currentUserPersonalDetails.accountID ?? '-1'; const userDisplayName = action.person?.[0]?.text; - const actorAccountID = action.actorAccountID ?? ''; + const actorAccountID = action.actorAccountID ?? '-1'; const displayName = actorAccountID === currentUserAccountID ? `${translate('common.you')}` : `${userDisplayName}`; const originalMessage = action.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED ? action.originalMessage : null; const oldName = originalMessage?.oldName ?? ''; diff --git a/src/components/ReportActionItem/ReportActionItemImage.tsx b/src/components/ReportActionItem/ReportActionItemImage.tsx index 4e7f123a2fb2..87a878603574 100644 --- a/src/components/ReportActionItem/ReportActionItemImage.tsx +++ b/src/components/ReportActionItem/ReportActionItemImage.tsx @@ -105,7 +105,7 @@ function ReportActionItemImage({ - Navigation.navigate(ROUTES.TRANSACTION_RECEIPT.getRoute(transactionThreadReport?.reportID ?? report?.reportID ?? '', transaction?.transactionID ?? '')) + Navigation.navigate(ROUTES.TRANSACTION_RECEIPT.getRoute(transactionThreadReport?.reportID ?? report?.reportID ?? '-1', transaction?.transactionID ?? '-1')) } accessibilityLabel={translate('accessibilityHints.viewAttachment')} accessibilityRole={CONST.ROLE.BUTTON} diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index 59968eb9062e..f40c41ba35ec 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -143,7 +143,7 @@ function ReportPreview({ const lastThreeReceipts = lastThreeTransactionsWithReceipts.map((transaction) => ReceiptUtils.getThumbnailAndImageURIs(transaction)); const showRTERViolationMessage = numberOfRequests === 1 && - TransactionUtils.hasPendingUI(allTransactions[0], TransactionUtils.getTransactionViolations(allTransactions[0]?.transactionID ?? '', transactionViolations)); + TransactionUtils.hasPendingUI(allTransactions[0], TransactionUtils.getTransactionViolations(allTransactions[0]?.transactionID ?? '-1', transactionViolations)); let formattedMerchant = numberOfRequests === 1 ? TransactionUtils.getMerchant(allTransactions[0]) : null; const formattedDescription = numberOfRequests === 1 ? TransactionUtils.getDescription(allTransactions[0]) : null; diff --git a/src/components/ReportActionItem/TaskPreview.tsx b/src/components/ReportActionItem/TaskPreview.tsx index 8e8b3b930be7..447d333d3e16 100644 --- a/src/components/ReportActionItem/TaskPreview.tsx +++ b/src/components/ReportActionItem/TaskPreview.tsx @@ -72,7 +72,7 @@ function TaskPreview({taskReport, taskReportID, action, contextMenuAnchor, chatR ? taskReport?.stateNum === CONST.REPORT.STATE_NUM.APPROVED && taskReport.statusNum === CONST.REPORT.STATUS_NUM.APPROVED : action?.childStateNum === CONST.REPORT.STATE_NUM.APPROVED && action?.childStatusNum === CONST.REPORT.STATUS_NUM.APPROVED; const taskTitle = Str.htmlEncode(TaskUtils.getTaskTitle(taskReportID, action?.childReportName ?? '')); - const taskAssigneeAccountID = Task.getTaskAssigneeAccountID(taskReport) ?? action?.childManagerAccountID ?? ''; + const taskAssigneeAccountID = Task.getTaskAssigneeAccountID(taskReport) ?? action?.childManagerAccountID ?? '-1'; const htmlForTaskPreview = taskAssigneeAccountID !== 0 ? ` ${taskTitle}` : `${taskTitle}`; const isDeletedParentAction = ReportUtils.isCanceledTaskReport(taskReport, action); diff --git a/src/components/SettlementButton.tsx b/src/components/SettlementButton.tsx index f56c4dd1a863..dd5411f6dd12 100644 --- a/src/components/SettlementButton.tsx +++ b/src/components/SettlementButton.tsx @@ -188,7 +188,7 @@ function SettlementButton({ // To achieve the one tap pay experience we need to choose the correct payment type as default. // If the user has previously chosen a specific payment option or paid for some expense, // let's use the last payment method or use default. - const paymentMethod = nvpLastPaymentMethod?.[policyID] ?? ''; + const paymentMethod = nvpLastPaymentMethod?.[policyID] ?? '-1'; if (canUseWallet) { buttonOptions.push(paymentMethods[CONST.IOU.PAYMENT_TYPE.EXPENSIFY]); } diff --git a/src/components/TaskHeaderActionButton.tsx b/src/components/TaskHeaderActionButton.tsx index 788734242f7b..0c7e603a4aa2 100644 --- a/src/components/TaskHeaderActionButton.tsx +++ b/src/components/TaskHeaderActionButton.tsx @@ -33,7 +33,7 @@ function TaskHeaderActionButton({report, session}: TaskHeaderActionButtonProps)