From 6600a7b3cff9aa41d8a58f5b2af79cd3181cea28 Mon Sep 17 00:00:00 2001
From: Adam Horodyski <ad.horodyski@gmail.com>
Date: Wed, 27 Mar 2024 18:06:17 +0100
Subject: [PATCH 1/5] chore: bump react-native-onyx to 2.0.23

---
 package-lock.json | 9 ++++-----
 package.json      | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index dc170b7a9572..b4725df3f965 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -94,7 +94,7 @@
         "react-native-linear-gradient": "^2.8.1",
         "react-native-localize": "^2.2.6",
         "react-native-modal": "^13.0.0",
-        "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx#cd778b55e419bf09ecf377b1e3ac013b7758434d",
+        "react-native-onyx": "2.0.23",
         "react-native-pager-view": "6.2.2",
         "react-native-pdf": "6.7.3",
         "react-native-performance": "^5.1.0",
@@ -39347,10 +39347,9 @@
       }
     },
     "node_modules/react-native-onyx": {
-      "version": "2.0.10",
-      "resolved": "git+ssh://git@github.com/Expensify/react-native-onyx.git#cd778b55e419bf09ecf377b1e3ac013b7758434d",
-      "integrity": "sha512-0ky9ISCNhuch0onIkeu/XFhVHoLp7gFwg6Q5TZYt1Wfmu/48Z9fjJxKxw5PRLfNBtwDQZQWKYFAf/CIoBxnmZw==",
-      "license": "MIT",
+      "version": "2.0.23",
+      "resolved": "https://registry.npmjs.org/react-native-onyx/-/react-native-onyx-2.0.23.tgz",
+      "integrity": "sha512-A0SuipCwAswl8+hBlr9tNPTBdxixKBJkcdP8YpgUC072/4Kcfvv0pfpfQOHoeCR/bP2wvDagpdN3VtebRfoVMg==",
       "dependencies": {
         "ascii-table": "0.0.9",
         "fast-equals": "^4.0.3",
diff --git a/package.json b/package.json
index 26918ddc1ce3..b304efce64da 100644
--- a/package.json
+++ b/package.json
@@ -145,7 +145,7 @@
     "react-native-linear-gradient": "^2.8.1",
     "react-native-localize": "^2.2.6",
     "react-native-modal": "^13.0.0",
-    "react-native-onyx": "git+https://github.com/Expensify/react-native-onyx#cd778b55e419bf09ecf377b1e3ac013b7758434d",
+    "react-native-onyx": "2.0.23",
     "react-native-pager-view": "6.2.2",
     "react-native-pdf": "6.7.3",
     "react-native-performance": "^5.1.0",

From fac2a37d5553f1247d6a6e2e5c682ccafc4e069a Mon Sep 17 00:00:00 2001
From: Blazej Kustra <blazej.kustra@swmansion.com>
Date: Thu, 28 Mar 2024 17:04:37 +0100
Subject: [PATCH 2/5] Fix TS related errors

---
 src/libs/actions/ActiveClients.ts                         | 2 +-
 src/libs/actions/BankAccounts.ts                          | 2 +-
 src/libs/actions/CachedPDFPaths/types.ts                  | 2 +-
 src/libs/actions/Download.ts                              | 2 +-
 src/libs/actions/OnyxUpdates.ts                           | 4 ++--
 src/libs/actions/ReimbursementAccount/index.ts            | 2 +-
 src/libs/actions/Report.ts                                | 2 +-
 src/libs/actions/Transaction.ts                           | 4 ++--
 src/libs/migrateOnyx.ts                                   | 6 +++---
 src/libs/migrations/CheckForPreviousReportActionID.ts     | 2 +-
 .../migrations/KeyReportActionsDraftByReportActionID.ts   | 2 +-
 src/setup/index.ts                                        | 2 --
 tests/actions/IOUTest.ts                                  | 3 ---
 tests/actions/PolicyTest.ts                               | 8 +++-----
 tests/unit/ReportActionsUtilsTest.ts                      | 2 +-
 tests/utils/wrapOnyxWithWaitForBatchedUpdates.ts          | 3 ++-
 16 files changed, 21 insertions(+), 27 deletions(-)

diff --git a/src/libs/actions/ActiveClients.ts b/src/libs/actions/ActiveClients.ts
index e59fdc14410e..a2ea87d10cd2 100644
--- a/src/libs/actions/ActiveClients.ts
+++ b/src/libs/actions/ActiveClients.ts
@@ -1,7 +1,7 @@
 import Onyx from 'react-native-onyx';
 import ONYXKEYS from '@src/ONYXKEYS';
 
-function setActiveClients(activeClients: string[]): Promise<void> {
+function setActiveClients(activeClients: string[]): Promise<void | void[]> {
     return Onyx.set(ONYXKEYS.ACTIVE_CLIENTS, activeClients);
 }
 
diff --git a/src/libs/actions/BankAccounts.ts b/src/libs/actions/BankAccounts.ts
index bb20b2b686ab..64527319c35a 100644
--- a/src/libs/actions/BankAccounts.ts
+++ b/src/libs/actions/BankAccounts.ts
@@ -56,7 +56,7 @@ type PersonalAddress = {
     requestorAddressZipCode?: string;
 };
 
-function clearPlaid(): Promise<void> {
+function clearPlaid(): Promise<void | void[]> {
     Onyx.set(ONYXKEYS.PLAID_LINK_TOKEN, '');
     Onyx.set(ONYXKEYS.PLAID_CURRENT_EVENT, null);
     return Onyx.set(ONYXKEYS.PLAID_DATA, PlaidDataProps.plaidDataDefaultProps);
diff --git a/src/libs/actions/CachedPDFPaths/types.ts b/src/libs/actions/CachedPDFPaths/types.ts
index 98b768c4645e..728759daaa98 100644
--- a/src/libs/actions/CachedPDFPaths/types.ts
+++ b/src/libs/actions/CachedPDFPaths/types.ts
@@ -1,4 +1,4 @@
-type Add = (id: string, path: string) => Promise<void>;
+type Add = (id: string, path: string) => Promise<void | void[]>;
 type Clear = (path: string) => Promise<void>;
 type ClearAll = () => void;
 type ClearByKey = (id: string) => void;
diff --git a/src/libs/actions/Download.ts b/src/libs/actions/Download.ts
index 6eb3b1f05b4b..e82744aa5d02 100644
--- a/src/libs/actions/Download.ts
+++ b/src/libs/actions/Download.ts
@@ -4,7 +4,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
 /**
  * Set whether an attachment is being downloaded so that a spinner can be shown.
  */
-function setDownload(sourceID: string, isDownloading: boolean): Promise<void> {
+function setDownload(sourceID: string, isDownloading: boolean): Promise<void | void[]> {
     return Onyx.merge(`${ONYXKEYS.COLLECTION.DOWNLOAD}${sourceID}`, {isDownloading});
 }
 
diff --git a/src/libs/actions/OnyxUpdates.ts b/src/libs/actions/OnyxUpdates.ts
index ab26ad330b6f..e093ce9a964b 100644
--- a/src/libs/actions/OnyxUpdates.ts
+++ b/src/libs/actions/OnyxUpdates.ts
@@ -1,4 +1,4 @@
-import type {OnyxEntry} from 'react-native-onyx';
+import type {OnyxEntry, OnyxUpdate} from 'react-native-onyx';
 import Onyx from 'react-native-onyx';
 import type {Merge} from 'type-fest';
 import Log from '@libs/Log';
@@ -27,7 +27,7 @@ function applyHTTPSOnyxUpdates(request: Request, response: Response) {
     console.debug('[OnyxUpdateManager] Applying https update');
     // For most requests we can immediately update Onyx. For write requests we queue the updates and apply them after the sequential queue has flushed to prevent a replay effect in
     // the UI. See https://github.com/Expensify/App/issues/12775 for more info.
-    const updateHandler = request?.data?.apiRequestType === CONST.API_REQUEST_TYPE.WRITE ? QueuedOnyxUpdates.queueOnyxUpdates : Onyx.update;
+    const updateHandler: (updates: OnyxUpdate[]) => Promise<unknown> = request?.data?.apiRequestType === CONST.API_REQUEST_TYPE.WRITE ? QueuedOnyxUpdates.queueOnyxUpdates : Onyx.update;
 
     // First apply any onyx data updates that are being sent back from the API. We wait for this to complete and then
     // apply successData or failureData. This ensures that we do not update any pending, loading, or other UI states contained
diff --git a/src/libs/actions/ReimbursementAccount/index.ts b/src/libs/actions/ReimbursementAccount/index.ts
index 57d785c5d1c9..62e5f8454cbd 100644
--- a/src/libs/actions/ReimbursementAccount/index.ts
+++ b/src/libs/actions/ReimbursementAccount/index.ts
@@ -13,7 +13,7 @@ export {setBankAccountFormValidationErrors, resetReimbursementAccount} from './e
  * - CONST.BANK_ACCOUNT.SETUP_TYPE.MANUAL to ask them to enter their accountNumber and routingNumber
  * - CONST.BANK_ACCOUNT.SETUP_TYPE.PLAID to ask them to login to their bank via Plaid
  */
-function setBankAccountSubStep(subStep: BankAccountSubStep | null): Promise<void> {
+function setBankAccountSubStep(subStep: BankAccountSubStep | null): Promise<void | void[]> {
     return Onyx.merge(ONYXKEYS.REIMBURSEMENT_ACCOUNT, {achData: {subStep}});
 }
 
diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts
index 8cea9cbd0dae..5405ce57da21 100644
--- a/src/libs/actions/Report.ts
+++ b/src/libs/actions/Report.ts
@@ -1069,7 +1069,7 @@ function saveReportCommentNumberOfLines(reportID: string, numberOfLines: number)
 }
 
 /** Immediate indication whether the report has a draft comment. */
-function setReportWithDraft(reportID: string, hasDraft: boolean): Promise<void> {
+function setReportWithDraft(reportID: string, hasDraft: boolean): Promise<void | void[]> {
     return Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {hasDraft});
 }
 
diff --git a/src/libs/actions/Transaction.ts b/src/libs/actions/Transaction.ts
index 123614f2e0bb..9ddaca686e95 100644
--- a/src/libs/actions/Transaction.ts
+++ b/src/libs/actions/Transaction.ts
@@ -107,7 +107,7 @@ function saveWaypoint(transactionID: string, index: string, waypoint: RecentWayp
     }
 }
 
-function removeWaypoint(transaction: OnyxEntry<Transaction>, currentIndex: string, isDraft?: boolean): Promise<void> {
+function removeWaypoint(transaction: OnyxEntry<Transaction>, currentIndex: string, isDraft?: boolean): Promise<void | void[]> {
     // Index comes from the route params and is a string
     const index = Number(currentIndex);
     const existingWaypoints = transaction?.comment?.waypoints ?? {};
@@ -234,7 +234,7 @@ function getRoute(transactionID: string, waypoints: WaypointCollection, isDraft:
  * @param waypoints - An object containing all the waypoints
  *                             which will replace the existing ones.
  */
-function updateWaypoints(transactionID: string, waypoints: WaypointCollection, isDraft = false): Promise<void> {
+function updateWaypoints(transactionID: string, waypoints: WaypointCollection, isDraft = false): Promise<void | void[]> {
     return Onyx.merge(`${isDraft ? ONYXKEYS.COLLECTION.TRANSACTION_DRAFT : ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {
         comment: {
             waypoints,
diff --git a/src/libs/migrateOnyx.ts b/src/libs/migrateOnyx.ts
index e8c0b2bf3e10..d827d9936fd1 100644
--- a/src/libs/migrateOnyx.ts
+++ b/src/libs/migrateOnyx.ts
@@ -6,11 +6,11 @@ import RemoveEmptyReportActionsDrafts from './migrations/RemoveEmptyReportAction
 import RenameReceiptFilename from './migrations/RenameReceiptFilename';
 import TransactionBackupsToCollection from './migrations/TransactionBackupsToCollection';
 
-export default function (): Promise<void> {
+export default function () {
     const startTime = Date.now();
     Log.info('[Migrate Onyx] start');
 
-    return new Promise((resolve) => {
+    return new Promise<void>((resolve) => {
         // Add all migrations to an array so they are executed in order
         const migrationPromises = [
             CheckForPreviousReportActionID,
@@ -25,7 +25,7 @@ export default function (): Promise<void> {
         // previous promise to finish before moving onto the next one.
         /* eslint-disable arrow-body-style */
         migrationPromises
-            .reduce((previousPromise, migrationPromise) => {
+            .reduce<Promise<void | void[]>>((previousPromise, migrationPromise) => {
                 return previousPromise.then(() => {
                     return migrationPromise();
                 });
diff --git a/src/libs/migrations/CheckForPreviousReportActionID.ts b/src/libs/migrations/CheckForPreviousReportActionID.ts
index d97bd87f0a2a..7e4bbe9ffb3e 100644
--- a/src/libs/migrations/CheckForPreviousReportActionID.ts
+++ b/src/libs/migrations/CheckForPreviousReportActionID.ts
@@ -21,7 +21,7 @@ function getReportActionsFromOnyx(): Promise<OnyxCollection<OnyxTypes.ReportActi
  * This migration checks for the 'previousReportActionID' key in the first valid reportAction of a report in Onyx.
  * If the key is not found then all reportActions for all reports are removed from Onyx.
  */
-export default function (): Promise<void> {
+export default function (): Promise<void | void[]> {
     return getReportActionsFromOnyx().then((allReportActions) => {
         if (Object.keys(allReportActions ?? {}).length === 0) {
             Log.info(`[Migrate Onyx] Skipped migration CheckForPreviousReportActionID because there were no reportActions`);
diff --git a/src/libs/migrations/KeyReportActionsDraftByReportActionID.ts b/src/libs/migrations/KeyReportActionsDraftByReportActionID.ts
index c8ef72ca15e7..193fdfe5f1eb 100644
--- a/src/libs/migrations/KeyReportActionsDraftByReportActionID.ts
+++ b/src/libs/migrations/KeyReportActionsDraftByReportActionID.ts
@@ -14,7 +14,7 @@ type ReportActionsDraftsKey = `${typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFT
  * After: reportActionsDrafts_reportID: {[reportActionID]: value}
  */
 export default function () {
-    return new Promise<void>((resolve) => {
+    return new Promise<void | void[]>((resolve) => {
         const connectionID = Onyx.connect({
             key: ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS,
             waitForCollectionCallback: true,
diff --git a/src/setup/index.ts b/src/setup/index.ts
index f79e6a461a3e..b1d90447ee5f 100644
--- a/src/setup/index.ts
+++ b/src/setup/index.ts
@@ -1,7 +1,6 @@
 import {I18nManager} from 'react-native';
 import Onyx from 'react-native-onyx';
 import intlPolyfill from '@libs/IntlPolyfill';
-import * as Metrics from '@libs/Metrics';
 import * as Device from '@userActions/Device';
 import CONST from '@src/CONST';
 import ONYXKEYS from '@src/ONYXKEYS';
@@ -29,7 +28,6 @@ export default function () {
         // Increase the cached key count so that the app works more consistently for accounts with large numbers of reports
         maxCachedKeysCount: 10000,
         safeEvictionKeys: [ONYXKEYS.COLLECTION.REPORT_ACTIONS],
-        captureMetrics: Metrics.canCaptureOnyxMetrics(),
         initialKeyStates: {
             // Clear any loading and error messages so they do not appear on app startup
             [ONYXKEYS.SESSION]: {loading: false},
diff --git a/tests/actions/IOUTest.ts b/tests/actions/IOUTest.ts
index c71a88809302..03134df037f3 100644
--- a/tests/actions/IOUTest.ts
+++ b/tests/actions/IOUTest.ts
@@ -397,7 +397,6 @@ describe('actions/IOU', () => {
                             new Promise<void>((resolve) => {
                                 const connectionID = Onyx.connect({
                                     key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
-                                    waitForCollectionCallback: true,
                                     callback: (transaction) => {
                                         Onyx.disconnect(connectionID);
                                         expect(transaction?.pendingAction).toBeFalsy();
@@ -2639,7 +2638,6 @@ describe('actions/IOU', () => {
             await new Promise<void>((resolve) => {
                 const connectionID = Onyx.connect({
                     key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`,
-                    waitForCollectionCallback: true,
                     callback: (report) => {
                         Onyx.disconnect(connectionID);
                         expect(report).toBeTruthy();
@@ -2696,7 +2694,6 @@ describe('actions/IOU', () => {
             await new Promise<void>((resolve) => {
                 const connectionID = Onyx.connect({
                     key: `${ONYXKEYS.COLLECTION.REPORT}${thread.reportID}`,
-                    waitForCollectionCallback: true,
                     callback: (report) => {
                         Onyx.disconnect(connectionID);
                         expect(report).toBeTruthy();
diff --git a/tests/actions/PolicyTest.ts b/tests/actions/PolicyTest.ts
index dfb8ae81d104..c673d39cd414 100644
--- a/tests/actions/PolicyTest.ts
+++ b/tests/actions/PolicyTest.ts
@@ -1,5 +1,5 @@
 import Onyx from 'react-native-onyx';
-import type {OnyxCollection} from 'react-native-onyx';
+import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
 import CONST from '@src/CONST';
 import OnyxUpdateManager from '@src/libs/actions/OnyxUpdateManager';
 import * as Policy from '@src/libs/actions/Policy';
@@ -41,10 +41,9 @@ describe('actions/Policy', () => {
             Policy.createWorkspace(ESH_EMAIL, true, WORKSPACE_NAME, policyID);
             await waitForBatchedUpdates();
 
-            let policy: OnyxCollection<PolicyType> = await new Promise((resolve) => {
+            let policy: OnyxEntry<PolicyType> | OnyxCollection<PolicyType> = await new Promise((resolve) => {
                 const connectionID = Onyx.connect({
                     key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
-                    waitForCollectionCallback: true,
                     callback: (workspace) => {
                         Onyx.disconnect(connectionID);
                         resolve(workspace);
@@ -61,10 +60,9 @@ describe('actions/Policy', () => {
             expect(policy?.isPolicyExpenseChatEnabled).toBe(true);
             expect(policy?.pendingAction).toBe(CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD);
 
-            const policyMembers: OnyxCollection<PolicyMembers> = await new Promise((resolve) => {
+            const policyMembers: OnyxEntry<PolicyMembers> = await new Promise((resolve) => {
                 const connectionID = Onyx.connect({
                     key: `${ONYXKEYS.COLLECTION.POLICY_MEMBERS}${policyID}`,
-                    waitForCollectionCallback: true,
                     callback: (members) => {
                         Onyx.disconnect(connectionID);
                         resolve(members);
diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts
index 5f0bb65cc3ab..f682dbab2597 100644
--- a/tests/unit/ReportActionsUtilsTest.ts
+++ b/tests/unit/ReportActionsUtilsTest.ts
@@ -1,4 +1,5 @@
 import Onyx from 'react-native-onyx';
+import type {CollectionKeyBase} from 'react-native-onyx/dist/types';
 import CONST from '../../src/CONST';
 import * as ReportActionsUtils from '../../src/libs/ReportActionsUtils';
 import ONYXKEYS from '../../src/ONYXKEYS';
@@ -1963,7 +1964,6 @@ describe('ReportActionsUtils', () => {
                             new Promise<void>((resolve) => {
                                 const connectionID = Onyx.connect({
                                     key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`,
-                                    waitForCollectionCallback: true,
                                     callback: () => {
                                         Onyx.disconnect(connectionID);
                                         const res = ReportActionsUtils.getLastVisibleAction(report.reportID);
diff --git a/tests/utils/wrapOnyxWithWaitForBatchedUpdates.ts b/tests/utils/wrapOnyxWithWaitForBatchedUpdates.ts
index 862f3281b2b8..084fce5d5c95 100644
--- a/tests/utils/wrapOnyxWithWaitForBatchedUpdates.ts
+++ b/tests/utils/wrapOnyxWithWaitForBatchedUpdates.ts
@@ -1,4 +1,5 @@
 import type Onyx from 'react-native-onyx';
+import type {Writable} from 'type-fest';
 import waitForBatchedUpdates from './waitForBatchedUpdates';
 
 /**
@@ -9,7 +10,7 @@ import waitForBatchedUpdates from './waitForBatchedUpdates';
  * This is a convinience function, which wraps the onyxInstance's
  * functions, to for the promises to resolve.
  */
-function wrapOnyxWithWaitForBatchedUpdates(onyxInstance: typeof Onyx) {
+function wrapOnyxWithWaitForBatchedUpdates(onyxInstance: Writable<typeof Onyx>) {
     const multiSetImpl = onyxInstance.multiSet;
     // eslint-disable-next-line no-param-reassign
     onyxInstance.multiSet = (...args) => multiSetImpl(...args).then((result) => waitForBatchedUpdates().then(() => result));

From 237400a68b053453a301693ad0ff5f2888cb34f6 Mon Sep 17 00:00:00 2001
From: hurali97 <hurali97@gmail.com>
Date: Fri, 29 Mar 2024 14:22:59 +0500
Subject: [PATCH 3/5] refactor: remove unused import

---
 tests/unit/ReportActionsUtilsTest.ts | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/unit/ReportActionsUtilsTest.ts b/tests/unit/ReportActionsUtilsTest.ts
index f682dbab2597..a926d0589e80 100644
--- a/tests/unit/ReportActionsUtilsTest.ts
+++ b/tests/unit/ReportActionsUtilsTest.ts
@@ -1,5 +1,4 @@
 import Onyx from 'react-native-onyx';
-import type {CollectionKeyBase} from 'react-native-onyx/dist/types';
 import CONST from '../../src/CONST';
 import * as ReportActionsUtils from '../../src/libs/ReportActionsUtils';
 import ONYXKEYS from '../../src/ONYXKEYS';

From 06f3e71cb7b813e58ca2b6e2ab67e2738e539898 Mon Sep 17 00:00:00 2001
From: hurali97 <hurali97@gmail.com>
Date: Wed, 3 Apr 2024 13:28:51 +0500
Subject: [PATCH 4/5] fix: infinite loop of logs

---
 src/libs/Console/index.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libs/Console/index.ts b/src/libs/Console/index.ts
index 423e1037a605..f03d33674bde 100644
--- a/src/libs/Console/index.ts
+++ b/src/libs/Console/index.ts
@@ -24,7 +24,7 @@ Onyx.connect({
 const originalConsoleLog = console.log;
 
 /* List of patterns to ignore in logs. "logs" key always needs to be ignored because otherwise it will cause infinite loop */
-const logPatternsToIgnore = [`merge() called for key: ${ONYXKEYS.LOGS}`];
+const logPatternsToIgnore = [`merge called for key: ${ONYXKEYS.LOGS}`];
 
 /**
  * Check if the log should be attached to the console

From a6c2cc98fba01f2193e1b5ba3fe7c353ab883c23 Mon Sep 17 00:00:00 2001
From: hurali97 <hurali97@gmail.com>
Date: Wed, 3 Apr 2024 17:49:38 +0500
Subject: [PATCH 5/5] fix: failing IOUTest

---
 src/libs/ErrorUtils.ts  | 2 +-
 src/libs/actions/IOU.ts | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/libs/ErrorUtils.ts b/src/libs/ErrorUtils.ts
index a93efb8cbff5..3487f05b9c05 100644
--- a/src/libs/ErrorUtils.ts
+++ b/src/libs/ErrorUtils.ts
@@ -40,7 +40,7 @@ function getAuthenticateErrorMessage(response: Response): keyof TranslationFlatO
  * Method used to get an error object with microsecond as the key.
  * @param error - error key or message to be saved
  */
-function getMicroSecondOnyxError(error: string | null, isTranslated = false, errorKey?: number): Errors {
+function getMicroSecondOnyxError(error: string, isTranslated = false, errorKey?: number): Errors {
     return {[errorKey ?? DateUtils.getMicroseconds()]: error && [error, {isTranslated}]};
 }
 
diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts
index 761ae02ea4c6..41952080d869 100644
--- a/src/libs/actions/IOU.ts
+++ b/src/libs/actions/IOU.ts
@@ -778,7 +778,7 @@ function buildOnyxDataForMoneyRequest(
                               errors: getReceiptError(transaction.receipt, transaction.filename || transaction.receipt?.filename, isScanRequest, errorKey),
                           },
                           [iouAction.reportActionID]: {
-                              errors: ErrorUtils.getMicroSecondOnyxError(null),
+                              errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage'),
                           },
                       }
                     : {
@@ -2507,7 +2507,7 @@ function createSplitsAndOnyxData(
                 key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${splitChatReport.reportID}`,
                 value: {
                     [splitIOUReportAction.reportActionID]: {
-                        errors: ErrorUtils.getMicroSecondOnyxError(null),
+                        errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage'),
                     },
                 },
             },
@@ -4319,7 +4319,7 @@ function getSendMoneyParams(
                 key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${optimisticIOUReport.reportID}`,
                 value: {
                     [optimisticIOUReportAction.reportActionID]: {
-                        errors: ErrorUtils.getMicroSecondOnyxError(null),
+                        errors: ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage'),
                     },
                 },
             },
