diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 748fbde53cc5..699e77abb25e 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -498,7 +498,7 @@ function Search({ const prevIsSearchResultEmpty = usePrevious(isSearchResultsEmpty); const [baseFilteredData, filteredDataLength, allDataLength] = useMemo(() => { - if (shouldDeferHeavySearchWork || searchResults === undefined || !isDataLoaded) { + if (shouldDeferHeavySearchWork || searchResults === undefined || !isDataLoaded || !searchResults.data) { return [[], 0, 0]; } diff --git a/src/hooks/useSearchLoadingState.ts b/src/hooks/useSearchLoadingState.ts index 4757426c8bd1..f44a2958c832 100644 --- a/src/hooks/useSearchLoadingState.ts +++ b/src/hooks/useSearchLoadingState.ts @@ -25,11 +25,14 @@ function useSearchLoadingState(queryJSON: SearchQueryJSON | undefined, searchRes const validGroupBy = getValidGroupBy(queryJSON.groupBy); const isCardFeedsLoading = validGroupBy === CONST.SEARCH.GROUP_BY.CARD && cardFeedsResult?.status === 'loading'; + const hasErrors = Object.keys(searchResults?.errors ?? {}).length > 0; + // Show page-level skeleton when no data has ever arrived for this query, // or when card feeds are still loading for card-grouped searches. // Once data arrives (even empty []), Search mounts and handles its own // loading/empty states internally via shouldShowLoadingState. - return hasNoData || isCardFeedsLoading; + // When errors are present, let Search mount so it can render FullPageErrorView. + return (hasNoData && !hasErrors) || isCardFeedsLoading; } export default useSearchLoadingState; diff --git a/src/libs/SearchUIUtils.ts b/src/libs/SearchUIUtils.ts index 1e58e60c33b2..db7b323953ed 100644 --- a/src/libs/SearchUIUtils.ts +++ b/src/libs/SearchUIUtils.ts @@ -4401,7 +4401,8 @@ function isSearchDataLoaded(searchResults: SearchResults | undefined, queryJSON: ? searchResults?.search?.status?.split(',').sort().join(',') : searchResults?.search?.status?.sort().join(','); const sortedQueryJSONStatus = Array.isArray(status) ? status.sort().join(',') : status; - const isDataLoaded = searchResults?.data !== undefined && searchResults?.search?.type === queryJSON?.type && sortedSearchResultStatus === sortedQueryJSONStatus; + const isDataLoaded = + (searchResults?.data != null || searchResults?.errors != null) && searchResults?.search?.type === queryJSON?.type && sortedSearchResultStatus === sortedQueryJSONStatus; return isDataLoaded; } diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index 6a994ee91cba..78bb84c93c6f 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -69,7 +69,7 @@ import type { TransactionViolations, ViolationName, } from '@src/types/onyx'; -import type {Attendee, Participant, SplitExpense} from '@src/types/onyx/IOU'; +import type {Attendee, DistanceExpenseType, Participant, SplitExpense} from '@src/types/onyx/IOU'; import type {Errors, PendingAction} from '@src/types/onyx/OnyxCommon'; import type {CurrentUserPersonalDetails} from '@src/types/onyx/PersonalDetails'; import type {OnyxData} from '@src/types/onyx/Request'; @@ -278,6 +278,15 @@ function isTimeRequest(transaction: OnyxEntry): boolean { return transaction?.comment?.type === CONST.TRANSACTION.TYPE.TIME; } +function isDistanceExpenseType(requestType: IOURequestType | undefined): requestType is DistanceExpenseType { + return ( + requestType === CONST.IOU.REQUEST_TYPE.DISTANCE_MAP || + requestType === CONST.IOU.REQUEST_TYPE.DISTANCE_MANUAL || + requestType === CONST.IOU.REQUEST_TYPE.DISTANCE_GPS || + requestType === CONST.IOU.REQUEST_TYPE.DISTANCE_ODOMETER + ); +} + function isCorporateCardTransaction(transaction: OnyxEntry): boolean { return isManagedCardTransaction(transaction) && transaction?.comment?.liabilityType === CONST.TRANSACTION.LIABILITY_TYPE.RESTRICT; } @@ -2864,6 +2873,7 @@ export { isGPSDistanceRequest, isManualDistanceRequest, isOdometerDistanceRequest, + isDistanceExpenseType, isFetchingWaypointsFromServer, isExpensifyCardTransaction, isManagedCardTransaction, diff --git a/src/libs/actions/Card.ts b/src/libs/actions/Card.ts index c97dd484d0e6..6d5c5dd9e5f2 100644 --- a/src/libs/actions/Card.ts +++ b/src/libs/actions/Card.ts @@ -70,8 +70,7 @@ function reportVirtualExpensifyCardFraud(card: Card, validateCode: string) { onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.FORMS.REPORT_VIRTUAL_CARD_FRAUD, value: { - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - cardID, + cardID: cardID.toString(), isLoading: true, errors: null, }, diff --git a/src/libs/actions/IOU/RejectMoneyRequest.ts b/src/libs/actions/IOU/RejectMoneyRequest.ts index 21c42a28a2a2..c67d4628c7fa 100644 --- a/src/libs/actions/IOU/RejectMoneyRequest.ts +++ b/src/libs/actions/IOU/RejectMoneyRequest.ts @@ -502,7 +502,6 @@ function prepareRejectMoneyRequestData( onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${rejectedToReportID}`, value: { - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 parentReportID: report?.chatReportID, }, }, @@ -902,11 +901,10 @@ function markRejectViolationAsResolved(transactionID: string, isOffline: boolean // Build optimistic data const optimisticData: Array> = [ - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, - value: updatedViolations, + value: updatedViolations ?? null, }, { onyxMethod: Onyx.METHOD.MERGE, @@ -930,11 +928,10 @@ function markRejectViolationAsResolved(transactionID: string, isOffline: boolean ]; const failureData: Array> = [ - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, - value: currentViolations, + value: currentViolations ?? null, }, { onyxMethod: Onyx.METHOD.MERGE, diff --git a/src/libs/actions/IOU/Split.ts b/src/libs/actions/IOU/Split.ts index cb62bc3fbe57..bdf5a5eaed3a 100644 --- a/src/libs/actions/IOU/Split.ts +++ b/src/libs/actions/IOU/Split.ts @@ -1950,11 +1950,10 @@ function updateSplitTransactions({ }, }); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 onyxData.failureData?.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${originalTransactionID}`, - value: originalTransaction, + value: originalTransaction ?? null, }); if (firstIOU) { diff --git a/src/libs/actions/IOU/index.ts b/src/libs/actions/IOU/index.ts index 0f25e9d1fcbb..6d8d63fcd17d 100644 --- a/src/libs/actions/IOU/index.ts +++ b/src/libs/actions/IOU/index.ts @@ -83,6 +83,7 @@ import { getCategoryTaxCodeAndAmount, getCurrency, getDistanceInMeters, + isDistanceExpenseType, isDistanceRequest as isDistanceRequestTransactionUtils, isManualDistanceRequest as isManualDistanceRequestTransactionUtils, isOdometerDistanceRequest as isOdometerDistanceRequestTransactionUtils, @@ -1695,8 +1696,7 @@ function buildOnyxDataForMoneyRequest(moneyRequestParams: BuildOnyxDataForMoneyR { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING}`, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - value: {[CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP]: DateUtils.getDBTime(date.valueOf())}, + value: {[CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.SCAN_TEST_TOOLTIP]: {timestamp: DateUtils.getDBTime(date.valueOf()), dismissedMethod: 'click'}}, }, { onyxMethod: Onyx.METHOD.MERGE, @@ -3461,16 +3461,10 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest const isGPSDistanceRequest = transaction.iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE_GPS; - if ( - transaction.iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE_MAP || - isGPSDistanceRequest || - isManualDistanceRequest || - transaction.iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE_ODOMETER - ) { + if (isDistanceExpenseType(transaction.iouRequestType)) { onyxData?.optimisticData?.push({ onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_LAST_DISTANCE_EXPENSE_TYPE, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 value: transaction.iouRequestType, }); } diff --git a/src/libs/actions/MergeTransaction.ts b/src/libs/actions/MergeTransaction.ts index 59c2f2e85901..76449ceb69bc 100644 --- a/src/libs/actions/MergeTransaction.ts +++ b/src/libs/actions/MergeTransaction.ts @@ -438,14 +438,13 @@ function mergeTransactionRequest({ ] : []; - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 const failureReportDeletionData: Array> = transactionsOfDeletableReport.length === 1 ? [ { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.REPORT}${transactionToDelete.reportID}`, - value: getReportOrDraftReport(transactionToDelete.reportID), + value: getReportOrDraftReport(transactionToDelete.reportID) ?? null, }, ] : []; diff --git a/src/libs/actions/Policy/Member.ts b/src/libs/actions/Policy/Member.ts index 46bee82ca352..90d7b590157c 100644 --- a/src/libs/actions/Policy/Member.ts +++ b/src/libs/actions/Policy/Member.ts @@ -451,6 +451,7 @@ function removeMembers(policy: OnyxEntry, selectedMemberEmails: string[] const pendingChatMembers = ReportUtils.getPendingChatMembers(accountIDs, [], CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); for (const report of workspaceChats) { + const currentTime = DateUtils.getDBTime(); optimisticData.push( { onyxMethod: Onyx.METHOD.MERGE, @@ -472,12 +473,10 @@ function removeMembers(policy: OnyxEntry, selectedMemberEmails: string[] onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`, value: { - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - private_isArchived: true, + private_isArchived: currentTime, }, }, ); - const currentTime = DateUtils.getDBTime(); const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`] ?? {}; for (const action of Object.values(reportActions)) { if (action.actionName !== CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) { @@ -517,8 +516,7 @@ function removeMembers(policy: OnyxEntry, selectedMemberEmails: string[] onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID}`, value: { - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - private_isArchived: false, + private_isArchived: null, }, }, ); diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 12f0b3cf8eb1..ffb87d0db24d 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -472,11 +472,10 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) { pendingAction: null, }, }, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_DOMAIN_MEMBER}${workspaceAccountID}`, - value: policyCardFeeds, + value: policyCardFeeds ?? null, }, ]; @@ -488,11 +487,10 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) { const newActivePolicyID = mostRecentlyCreatedGroupPolicy?.id ?? personalPolicyID; - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_ACTIVE_POLICY_ID, - value: newActivePolicyID, + value: newActivePolicyID ?? null, }); failureData.push({ @@ -590,17 +588,15 @@ function deleteWorkspace(params: DeleteWorkspaceActionParams) { for (const transactionViolationKey of Object.keys(transactionViolations ?? {})) { const transactionViolation = transactionViolations?.[transactionViolationKey]; const transactionID = transactionViolationKey.slice(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS.length); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, - value: transactionViolation?.filter((violation) => violation.type !== CONST.VIOLATION_TYPES.VIOLATION), + value: transactionViolation?.filter((violation) => violation.type !== CONST.VIOLATION_TYPES.VIOLATION) ?? null, }); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`, - value: transactionViolation, + value: transactionViolation ?? null, }); } } @@ -1574,8 +1570,7 @@ function createPolicyExpenseChats( onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${oldChat.reportID}`, value: { - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - private_isArchived: false, + private_isArchived: null, }, }); const currentTime = DateUtils.getDBTime(); diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index 6629e8fc22ad..83929aa1417d 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -3660,8 +3660,7 @@ function buildNewReportOptimisticData( { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - value: {[reportActionID]: {errorFields: {createReport: getMicroSecondOnyxErrorWithTranslationKey('report.genericCreateReportFailureMessage')}}}, + value: {[reportActionID]: {errors: {createReport: getMicroSecondOnyxErrorWithTranslationKey('report.genericCreateReportFailureMessage')}}}, }, { @@ -3690,8 +3689,7 @@ function buildNewReportOptimisticData( value: { [reportActionID]: { pendingAction: null, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - errorFields: null, + errors: null, }, }, }, @@ -3701,8 +3699,7 @@ function buildNewReportOptimisticData( value: { [reportPreviewReportActionID]: { pendingAction: null, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - errorFields: null, + errors: null, }, }, }, @@ -5973,11 +5970,10 @@ function deleteAppReport({ value: null, }); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, - value: reportActionsForReport, + value: reportActionsForReport ?? null, }); // 7. Mark the iouReport as being deleted and then delete it @@ -6471,12 +6467,11 @@ function dismissChangePolicyModal() { value: { [CONST.CHANGE_POLICY_TRAINING_MODAL]: { timestamp: DateUtils.getDBTime(date.valueOf()), - dismissedMethod: 'click', + dismissedMethod: 'click' as const, }, }, }, ]; - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 API.write(WRITE_COMMANDS.DISMISS_PRODUCT_TRAINING, {name: CONST.CHANGE_POLICY_TRAINING_MODAL, dismissedMethod: 'click'}, {optimisticData}); } @@ -6722,11 +6717,10 @@ function buildOptimisticChangePolicyData( }, }); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${reportID}`, - value: reportNextStep, + value: reportNextStep ?? null, }); failureData.push({ onyxMethod: Onyx.METHOD.MERGE, @@ -7100,6 +7094,7 @@ function changeReportPolicyAndInviteSubmitter({ employeeList, formatPhoneNumber, isReportLastVisibleArchived, + reportNextStep, }: { report: Report; parentReport: OnyxEntry; @@ -7112,6 +7107,7 @@ function changeReportPolicyAndInviteSubmitter({ employeeList: PolicyEmployeeList | undefined; formatPhoneNumber: LocaleContextProps['formatPhoneNumber']; isReportLastVisibleArchived: boolean | undefined; + reportNextStep: OnyxEntry; }) { if (!report.reportID || !policy?.id || report.policyID === policy.id || !isExpenseReport(report) || !report.ownerAccountID) { return; @@ -7159,7 +7155,7 @@ function changeReportPolicyAndInviteSubmitter({ hasViolationsParam, isASAPSubmitBetaEnabled, isReportLastVisibleArchived, - undefined, + reportNextStep, membersChats.reportCreationData[submitterEmail], ); diff --git a/src/libs/actions/Search.ts b/src/libs/actions/Search.ts index 4e949993d5b2..86d50563472f 100644 --- a/src/libs/actions/Search.ts +++ b/src/libs/actions/Search.ts @@ -340,12 +340,11 @@ function getOnyxLoadingData( ]; const failureData: Array> = [ - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 { onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.SNAPSHOT}${hash}`, value: { - ...(isOffline ? {} : {data: []}), + ...(isOffline ? {} : {data: null}), search: { status: queryJSON?.status, type: queryJSON?.type, @@ -1652,8 +1651,7 @@ function setOptimisticDataForTransactionThreadPreview(item: TransactionListItemT const onyxUpdates: Array> = []; // Set optimistic parent report - if (!hasParentReport) { - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 + if (!hasParentReport && report) { onyxUpdates.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, diff --git a/src/libs/actions/TaxRate.ts b/src/libs/actions/TaxRate.ts index 07f9a4b942b2..3a6373108e95 100644 --- a/src/libs/actions/TaxRate.ts +++ b/src/libs/actions/TaxRate.ts @@ -342,13 +342,14 @@ function deletePolicyTaxes(policy: OnyxEntry, taxesToDelete: string[], l return acc; }, {}), }, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - customUnits: distanceRateCustomUnit && - customUnitID && { - [customUnitID]: { - rates: optimisticRates, - }, - }, + customUnits: + distanceRateCustomUnit && customUnitID + ? { + [customUnitID]: { + rates: optimisticRates, + }, + } + : undefined, }, }, ], @@ -364,13 +365,14 @@ function deletePolicyTaxes(policy: OnyxEntry, taxesToDelete: string[], l return acc; }, {}), }, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - customUnits: distanceRateCustomUnit && - customUnitID && { - [customUnitID]: { - rates: successRates, - }, - }, + customUnits: + distanceRateCustomUnit && customUnitID + ? { + [customUnitID]: { + rates: successRates, + }, + } + : undefined, }, }, ], @@ -390,13 +392,14 @@ function deletePolicyTaxes(policy: OnyxEntry, taxesToDelete: string[], l return acc; }, {}), }, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - customUnits: distanceRateCustomUnit && - customUnitID && { - [customUnitID]: { - rates: failureRates, - }, - }, + customUnits: + distanceRateCustomUnit && customUnitID + ? { + [customUnitID]: { + rates: failureRates, + }, + } + : undefined, }, }, ], diff --git a/src/libs/actions/Transaction.ts b/src/libs/actions/Transaction.ts index d26db60e381e..ceb5e9e5bf1b 100644 --- a/src/libs/actions/Transaction.ts +++ b/src/libs/actions/Transaction.ts @@ -606,7 +606,6 @@ function dismissDuplicateTransactionViolation({ }); } - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 const optimisticReportActions: Array> = transactionsReportActions.map((action, index) => { const optimisticDismissedViolationReportAction = optimisticDismissedViolationReportActions.at(index); return { @@ -616,7 +615,7 @@ function dismissDuplicateTransactionViolation({ ? { [optimisticDismissedViolationReportAction.reportActionID]: optimisticDismissedViolationReportAction as ReportAction, } - : undefined, + : null, }; }); const optimisticDataTransactionViolations: Array> = currentTransactionViolations.map((transactionViolations) => ({ @@ -660,7 +659,6 @@ function dismissDuplicateTransactionViolation({ }, })); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 const failureReportActions: Array> = transactionsReportActions.map((action, index) => { const optimisticDismissedViolationReportAction = optimisticDismissedViolationReportActions.at(index); return { @@ -670,7 +668,7 @@ function dismissDuplicateTransactionViolation({ ? { [optimisticDismissedViolationReportAction.reportActionID]: null, } - : undefined, + : null, }; }); @@ -678,7 +676,6 @@ function dismissDuplicateTransactionViolation({ failureData.push(...failureDataTransaction); failureData.push(...failureReportActions); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 const successReportActions: Array> = transactionsReportActions.map((action, index) => { const optimisticDismissedViolationReportAction = optimisticDismissedViolationReportActions.at(index); return { @@ -688,7 +685,7 @@ function dismissDuplicateTransactionViolation({ ? { [optimisticDismissedViolationReportAction.reportActionID]: null, } - : undefined, + : null, }; }); successData.push(...successReportActions); @@ -1134,11 +1131,10 @@ function changeTransactionsReport({ false, ); optimisticData.push(violationData); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`, - value: allTransactionViolation?.[transaction.transactionID], + value: allTransactionViolation?.[transaction.transactionID] ?? null, }); const transactionHasViolations = Array.isArray(violationData.value) && violationData.value.length > 0; const hasOtherViolationsBesideDuplicates = @@ -1307,10 +1303,9 @@ function changeTransactionsReport({ failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT}${oldIOUAction.childReportID}`, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 value: { parentReportID: isUnreportedExpense ? selfDMReportID : oldReportID, - optimisticMoneyRequestReportActionID: oldIOUAction.reportActionID, + parentReportActionID: oldIOUAction.reportActionID, policyID: allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${oldIOUAction.reportActionID}`]?.policyID, }, }); @@ -1624,11 +1619,10 @@ function changeTransactionsReport({ }, }, }); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 failureData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${nextStepOnyxReportID}`, - value: nextStepOnyxReportID === reportID ? reportNextStep : (affectedReport.nextStep ?? null), + value: nextStepOnyxReportID === reportID ? (reportNextStep ?? null) : (affectedReport.nextStep ?? null), }); failureData.push({ onyxMethod: Onyx.METHOD.MERGE, diff --git a/src/libs/actions/Travel.ts b/src/libs/actions/Travel.ts index a56510c14099..4b06017bede9 100644 --- a/src/libs/actions/Travel.ts +++ b/src/libs/actions/Travel.ts @@ -73,8 +73,7 @@ function requestTravelAccess() { onyxMethod: 'merge', key: ONYXKEYS.NVP_TRAVEL_SETTINGS, value: { - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - lastTravelSignupRequestTime: Date.now(), + lastTravelSignupRequestTime: Date.now().toString(), }, }, ]; diff --git a/src/libs/actions/User.ts b/src/libs/actions/User.ts index 0b1bec9825fb..de905b137efb 100644 --- a/src/libs/actions/User.ts +++ b/src/libs/actions/User.ts @@ -56,6 +56,7 @@ import type {AnyOnyxServerUpdate, OnyxServerUpdate, OnyxUpdateEvent} from '@src/ import type OnyxPersonalDetails from '@src/types/onyx/PersonalDetails'; import type {Status} from '@src/types/onyx/PersonalDetails'; import type ReportAction from '@src/types/onyx/ReportAction'; +import type {AnyOnyxUpdate} from '@src/types/onyx/Request'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; import type PrefixedRecord from '@src/types/utils/PrefixedRecord'; import {reconnectApp} from './App'; @@ -1324,14 +1325,13 @@ function dismissReferralBanner(type: ValueOf(name: TKey, value: SetNameValuePairParams['value'], revertedValue: SetNameValuePairParams['value'], shouldRevertValue = true) { const parameters: SetNameValuePairParams = { name, value: typeof value === 'object' && value != null ? JSON.stringify(value) : value, }; - const optimisticData: Array> = [ - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 + const optimisticData: AnyOnyxUpdate[] = [ { onyxMethod: Onyx.METHOD.MERGE, key: name, @@ -1339,8 +1339,7 @@ function setNameValuePair(name: OnyxKey, value: SetNameValuePairParams['value'], }, ]; - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - const failureData: Array> | undefined = shouldRevertValue + const failureData: AnyOnyxUpdate[] | undefined = shouldRevertValue ? [ { onyxMethod: Onyx.METHOD.MERGE, diff --git a/src/libs/actions/VacationDelegate.ts b/src/libs/actions/VacationDelegate.ts index 25207a3338fd..5d129804524b 100644 --- a/src/libs/actions/VacationDelegate.ts +++ b/src/libs/actions/VacationDelegate.ts @@ -41,8 +41,7 @@ function setVacationDelegate(creator: string, delegate: string, shouldOverridePo onyxMethod: Onyx.METHOD.MERGE, key: ONYXKEYS.NVP_PRIVATE_VACATION_DELEGATE, value: { - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - errors: ErrorUtils.getMicroSecondTranslationErrorWithTranslationKey('statusPage.vacationDelegateError'), + errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('statusPage.vacationDelegateError'), }, }, ]; @@ -96,8 +95,7 @@ function deleteVacationDelegate(vacationDelegate?: VacationDelegate) { value: { creator, delegate, - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - errors: ErrorUtils.getMicroSecondTranslationErrorWithTranslationKey('statusPage.vacationDelegateError'), + errors: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('statusPage.vacationDelegateError'), }, }, ]; diff --git a/src/pages/ReportChangeWorkspacePage.tsx b/src/pages/ReportChangeWorkspacePage.tsx index 46cc64c53776..b61db4e57e4e 100644 --- a/src/pages/ReportChangeWorkspacePage.tsx +++ b/src/pages/ReportChangeWorkspacePage.tsx @@ -112,6 +112,7 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro employeeList, formatPhoneNumber, isReportLastVisibleArchived, + reportNextStep, }); } else { changeReportPolicy( diff --git a/src/pages/Search/SearchPage.tsx b/src/pages/Search/SearchPage.tsx index 08eadbdd13ba..19d47a6cff68 100644 --- a/src/pages/Search/SearchPage.tsx +++ b/src/pages/Search/SearchPage.tsx @@ -57,7 +57,7 @@ function SearchPage({route}: SearchPageProps) { const [isSorting, setIsSorting] = useState(false); let searchResults: SearchResults | undefined; - if (currentSearchResults?.data !== undefined) { + if (currentSearchResults?.data != null || currentSearchResults?.errors) { searchResults = currentSearchResults; } else if (isSorting) { searchResults = lastNonEmptySearchResults.current; diff --git a/src/stories/EReceipt.stories.tsx b/src/stories/EReceipt.stories.tsx index 061a6f4fe2b4..10bf8bc83014 100644 --- a/src/stories/EReceipt.stories.tsx +++ b/src/stories/EReceipt.stories.tsx @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/naming-convention, rulesdir/prefer-actions-set-data */ import type {Meta, StoryFn} from '@storybook/react-webpack5'; import React from 'react'; +import type {OnyxMergeCollectionInput} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {EReceiptProps} from '@components/EReceipt'; import EReceipt from '@components/EReceipt'; import ONYXKEYS from '@src/ONYXKEYS'; -import type CollectionDataSet from '@src/types/utils/CollectionDataSet'; type EReceiptStory = StoryFn; @@ -151,9 +151,8 @@ const transactionData = { created: '2023-01-11 13:46:20', hasEReceipt: true, }, -} as CollectionDataSet; +} as OnyxMergeCollectionInput; -// @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 Onyx.mergeCollection(ONYXKEYS.COLLECTION.TRANSACTION, transactionData); Onyx.merge('cardList', { 4: {bank: 'Expensify Card', lastFourPAN: '1000'}, diff --git a/src/types/onyx/IOU.ts b/src/types/onyx/IOU.ts index 8624b145a8a7..875e46c17d3c 100644 --- a/src/types/onyx/IOU.ts +++ b/src/types/onyx/IOU.ts @@ -270,7 +270,11 @@ type Accountant = { }; /** Type of distance expense */ -type DistanceExpenseType = typeof CONST.IOU.REQUEST_TYPE.DISTANCE_MAP | typeof CONST.IOU.REQUEST_TYPE.DISTANCE_MANUAL; +type DistanceExpenseType = + | typeof CONST.IOU.REQUEST_TYPE.DISTANCE_MAP + | typeof CONST.IOU.REQUEST_TYPE.DISTANCE_MANUAL + | typeof CONST.IOU.REQUEST_TYPE.DISTANCE_GPS + | typeof CONST.IOU.REQUEST_TYPE.DISTANCE_ODOMETER; export default IOU; export type {Participant, Split, Attendee, Accountant, SplitExpense, DistanceExpenseType}; diff --git a/src/types/onyx/ReportNameValuePairs.ts b/src/types/onyx/ReportNameValuePairs.ts index 82dc02b12103..9f2e4730d435 100644 --- a/src/types/onyx/ReportNameValuePairs.ts +++ b/src/types/onyx/ReportNameValuePairs.ts @@ -85,6 +85,9 @@ type ReportNameValuePairs = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Agent Zero processing request indicator message */ agentZeroProcessingRequestIndicator?: string; + /** Parent report ID */ + parentReportID?: string; + /** Title field configuration copied from policy - presence indicates auto-generated names are allowed */ // eslint-disable-next-line @typescript-eslint/naming-convention expensify_text_title?: { diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts index a9d10dc7613a..841660f39803 100644 --- a/tests/actions/IOUTest.ts +++ b/tests/actions/IOUTest.ts @@ -4,7 +4,7 @@ import {renderHook, waitFor} from '@testing-library/react-native'; import {format} from 'date-fns'; import {deepEqual} from 'fast-equals'; import Onyx from 'react-native-onyx'; -import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; +import type {OnyxCollection, OnyxEntry, OnyxMergeCollectionInput} from 'react-native-onyx'; import type {SearchQueryJSON, SearchStatus} from '@components/Search/types'; import useOnyx from '@hooks/useOnyx'; import {clearAllRelatedReportActionErrors} from '@libs/actions/ClearReportActionErrors'; @@ -3929,17 +3929,13 @@ describe('actions/IOU', () => { (item) => item[julesChatCreatedAction.reportActionID].reportID, ); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - return Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, { - ...reportCollectionDataSet, - }) + return Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, reportCollectionDataSet as OnyxMergeCollectionInput) .then(() => - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT_ACTIONS, { ...carlosActionsCollectionDataSet, ...julesCreatedActionsCollectionDataSet, ...julesActionsCollectionDataSet, - }), + } as OnyxMergeCollectionInput), ) .then(() => Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${julesExistingTransaction?.transactionID}`, julesExistingTransaction)) .then(() => { diff --git a/tests/actions/IOUTest/SplitTest.ts b/tests/actions/IOUTest/SplitTest.ts index 7d82a30cae8d..107c8dc19188 100644 --- a/tests/actions/IOUTest/SplitTest.ts +++ b/tests/actions/IOUTest/SplitTest.ts @@ -2,7 +2,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ import {deepEqual} from 'fast-equals'; import Onyx from 'react-native-onyx'; -import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; +import type {OnyxCollection, OnyxEntry, OnyxMergeCollectionInput} from 'react-native-onyx'; import {getReportPreviewAction} from '@libs/actions/IOU'; import {putOnHold} from '@libs/actions/IOU/Hold'; import {requestMoney} from '@libs/actions/IOU/TrackExpense'; @@ -360,17 +360,13 @@ describe('split expense', () => { (item) => item[julesChatCreatedAction.reportActionID].reportID, ); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - return Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, { - ...reportCollectionDataSet, - }) + return Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, reportCollectionDataSet as OnyxMergeCollectionInput) .then(() => - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT_ACTIONS, { ...carlosActionsCollectionDataSet, ...julesCreatedActionsCollectionDataSet, ...julesActionsCollectionDataSet, - }), + } as OnyxMergeCollectionInput), ) .then(() => Onyx.set(`${ONYXKEYS.COLLECTION.TRANSACTION}${julesExistingTransaction?.transactionID}`, julesExistingTransaction)) .then(() => { diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index ac43b035d785..d9a91212985b 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -3280,6 +3280,7 @@ describe('actions/Report', () => { }, formatPhoneNumber: TestHelper.formatPhoneNumber, isReportLastVisibleArchived: undefined, + reportNextStep: undefined, }); await waitForBatchedUpdates(); @@ -3366,6 +3367,7 @@ describe('actions/Report', () => { employeeList, formatPhoneNumber: TestHelper.formatPhoneNumber, isReportLastVisibleArchived: false, + reportNextStep: undefined, }); await waitForBatchedUpdates(); diff --git a/tests/unit/APITest.ts b/tests/unit/APITest.ts index f6b0066dfea0..ea9451849170 100644 --- a/tests/unit/APITest.ts +++ b/tests/unit/APITest.ts @@ -3,6 +3,7 @@ import type {ValueOf} from 'type-fest'; import type {EnablePolicyFeatureCommand} from '@libs/actions/RequestConflictUtils'; import type {ApiRequestCommandParameters, ReadCommand, WriteCommand} from '@libs/API/types'; import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; import * as PersistedRequests from '@src/libs/actions/PersistedRequests'; import * as API from '@src/libs/API'; import HttpUtils from '@src/libs/HttpUtils'; @@ -809,7 +810,7 @@ describe('APITests', () => { { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, - value: 'onboarding.errorSelection', + value: 'onboarding.errorSelection' as TranslationPaths, }, ]; @@ -818,8 +819,7 @@ describe('APITests', () => { [ONYXKEYS.NETWORK]: {isOffline: false}, }) .then(() => { - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - API.write('MockCommand' as WriteCommand, {} as ApiRequestCommandParameters[WriteCommand], {failureData}); + API.write('MockCommand' as WriteCommand, {} as ApiRequestCommandParameters[WriteCommand], {failureData}); return waitForNetworkPromises(); }) .then(waitForBatchedUpdates) diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index fce1994b920e..c4ed63b42fa8 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -2,7 +2,7 @@ import {beforeAll} from '@jest/globals'; import {act, renderHook} from '@testing-library/react-native'; import {addDays, format as formatDate} from 'date-fns'; -import type {OnyxCollection, OnyxEntry, OnyxKey} from 'react-native-onyx'; +import type {OnyxCollection, OnyxEntry, OnyxKey, OnyxMergeCollectionInput} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {LocaleContextProps} from '@components/LocaleContextProvider'; import OnyxListItemProvider from '@components/OnyxListItemProvider'; @@ -5745,8 +5745,7 @@ describe('ReportUtils', () => { [invoiceReport, taskReport, iouReport, groupChatReport, oneOnOneChatReport], (item) => item.reportID, ); - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - return Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, reportCollectionDataSet); + return Onyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, reportCollectionDataSet as OnyxMergeCollectionInput); }); it('should return the 1:1 chat', () => { const report = getChatByParticipants([currentUserAccountID, userAccountID]); @@ -7044,8 +7043,7 @@ describe('ReportUtils', () => { const archivedReport: Report = createRandomReport(1, CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); const nonArchivedReport: Report = createRandomReport(2, CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); beforeAll(async () => { - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - await Onyx.setCollection(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, { + await Onyx.setCollection(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, { [`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${archivedReport.reportID}`]: {private_isArchived: DateUtils.getDBTime()}, }); }); @@ -7075,8 +7073,7 @@ describe('ReportUtils', () => { const archivedReport: Report = createRandomReport(1, CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); const nonArchivedReport: Report = createRandomReport(2, CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT); beforeAll(async () => { - // @ts-expect-error - will be solved in https://github.com/Expensify/App/issues/73830 - await Onyx.setCollection(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, { + await Onyx.setCollection(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, { [`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${archivedReport.reportID}`]: {private_isArchived: DateUtils.getDBTime()}, }); }); diff --git a/tests/unit/TransactionTest.ts b/tests/unit/TransactionTest.ts index 89f6dc449ee5..71952a667a7e 100644 --- a/tests/unit/TransactionTest.ts +++ b/tests/unit/TransactionTest.ts @@ -364,7 +364,7 @@ describe('Transaction', () => { const nextStepFailureData = failureData?.find((data) => data.key === `${ONYXKEYS.COLLECTION.NEXT_STEP}${FAKE_NEW_REPORT_ID}`); expect(nextStepFailureData).toBeDefined(); - expect(nextStepFailureData?.value).toBeUndefined(); + expect(nextStepFailureData?.value).toBeNull(); mockAPIWrite.mockRestore(); });