From 4c49adf27e39c67bba0134615e9fe0eee8fc38a9 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Fri, 9 Feb 2024 10:22:43 +0000 Subject: [PATCH 1/5] fix: update lastActorAccountID for transactionThread --- src/libs/actions/IOU.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index e16f879b6913..8855ce2be1f7 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1107,7 +1107,7 @@ function getUpdateMoneyRequestParams( }); } - // Optimistically modify the transaction + // Optimistically modify the transaction and the transaction thread optimisticData.push({ onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, @@ -1119,6 +1119,14 @@ function getUpdateMoneyRequestParams( }, }); + optimisticData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, + value: { + lastActorAccountID: updatedReportAction.actorAccountID, + }, + }); + if (isScanning && ('amount' in transactionChanges || 'currency' in transactionChanges)) { optimisticData.push( { From 084a25cbffa10d4dfd2047e472333527f3ea2f9b Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Fri, 9 Feb 2024 10:46:30 +0000 Subject: [PATCH 2/5] fix: reset transaction thread on failure --- src/libs/actions/IOU.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 8855ce2be1f7..edf849c35bc8 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1205,6 +1205,15 @@ function getUpdateMoneyRequestParams( }); } + if (transactionThread) { + // Reset the transaction thread to its original state + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, + value: transactionThread, + }); + } + return { params, onyxData: {optimisticData, successData, failureData}, From 23e79b9f57836f81c0396a8af2ed7cafa93adc8f Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Fri, 9 Feb 2024 11:32:34 +0000 Subject: [PATCH 3/5] fix: remove unnecessary condition --- ios/Podfile.lock | 4 +-- src/libs/actions/IOU.ts | 55 ++++++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 1664c982ce50..534fd6bb30c8 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1981,8 +1981,8 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: fda554d8751e395effcc87749f8b7c198c1031be - Yoga: 13c8ef87792450193e117976337b8527b49e8c03 + Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047 PODFILE CHECKSUM: 0ccbb4f2406893c6e9f266dc1e7470dcd72885d2 -COCOAPODS: 1.13.0 +COCOAPODS: 1.12.1 diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index edf849c35bc8..7d669bc736eb 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -261,7 +261,11 @@ function clearMoneyRequest(transactionID: string) { // eslint-disable-next-line @typescript-eslint/naming-convention function setMoneyRequestAmount_temporaryForRefactor(transactionID: string, amount: number, currency: string, removeOriginalCurrency = false) { if (removeOriginalCurrency) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {amount, currency, originalCurrency: null}); + Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, { + amount, + currency, + originalCurrency: null, + }); return; } Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {amount, currency}); @@ -357,7 +361,11 @@ function resetMoneyRequestInfo(id = '') { function getReceiptError(receipt?: Receipt, filename?: string, isScanRequest = true): Errors | ErrorFields { return isEmptyObject(receipt) || !isScanRequest ? ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage') - : ErrorUtils.getMicroSecondOnyxErrorObject({error: CONST.IOU.RECEIPT_ERROR, source: receipt.source?.toString() ?? '', filename: filename ?? ''}); + : ErrorUtils.getMicroSecondOnyxErrorObject({ + error: CONST.IOU.RECEIPT_ERROR, + source: receipt.source?.toString() ?? '', + filename: filename ?? '', + }); } /** Return the object to update hasOutstandingChildRequest */ @@ -1205,14 +1213,12 @@ function getUpdateMoneyRequestParams( }); } - if (transactionThread) { - // Reset the transaction thread to its original state - failureData.push({ - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, - value: transactionThread, - }); - } + // Reset the transaction thread to its original state + failureData.push({ + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${transactionThreadReportID}`, + value: transactionThread, + }); return { params, @@ -1565,7 +1571,13 @@ function createSplitsAndOnyxData( // Loop through participants creating individual chats, iouReports and reportActionIDs as needed const splitAmount = IOUUtils.calculateAmount(participants.length, amount, currency, false); - const splits: Split[] = [{email: currentUserEmailForIOUSplit, accountID: currentUserAccountID, amount: IOUUtils.calculateAmount(participants.length, amount, currency, true)}]; + const splits: Split[] = [ + { + email: currentUserEmailForIOUSplit, + accountID: currentUserAccountID, + amount: IOUUtils.calculateAmount(participants.length, amount, currency, true), + }, + ]; const hasMultipleParticipants = participants.length > 1; participants.forEach((participant) => { @@ -3581,9 +3593,17 @@ function setMoneyRequestParticipantsFromReport(transactionID: string, report: On const currentUserAccountID = currentUserPersonalDetails.accountID; const participants: Participant[] = ReportUtils.isPolicyExpenseChat(chatReport) ? [{reportID: chatReport?.reportID, isPolicyExpenseChat: true, selected: true}] - : (chatReport?.participantAccountIDs ?? []).filter((accountID) => currentUserAccountID !== accountID).map((accountID) => ({accountID, selected: true})); - - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {participants, participantsAutoAssigned: true}); + : (chatReport?.participantAccountIDs ?? []) + .filter((accountID) => currentUserAccountID !== accountID) + .map((accountID) => ({ + accountID, + selected: true, + })); + + Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, { + participants, + participantsAutoAssigned: true, + }); } /** Initialize money request info and navigate to the MoneyRequest page */ @@ -3671,7 +3691,12 @@ function navigateToNextPage(iou: OnyxEntry, iouType: string, repo const currentUserAccountID = currentUserPersonalDetails.accountID; const participants: Participant[] = ReportUtils.isPolicyExpenseChat(chatReport) ? [{reportID: chatReport?.reportID, isPolicyExpenseChat: true, selected: true}] - : (chatReport?.participantAccountIDs ?? []).filter((accountID) => currentUserAccountID !== accountID).map((accountID) => ({accountID, selected: true})); + : (chatReport?.participantAccountIDs ?? []) + .filter((accountID) => currentUserAccountID !== accountID) + .map((accountID) => ({ + accountID, + selected: true, + })); setMoneyRequestParticipants(participants); resetMoneyRequestCategory(); } From e3dde0e772c591406a9b85804ee47ee852c56469 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Fri, 9 Feb 2024 11:38:17 +0000 Subject: [PATCH 4/5] fix: revert podfile changes --- ios/Podfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 534fd6bb30c8..1664c982ce50 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1981,8 +1981,8 @@ SPEC CHECKSUMS: SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2 VisionCamera: fda554d8751e395effcc87749f8b7c198c1031be - Yoga: e64aa65de36c0832d04e8c7bd614396c77a80047 + Yoga: 13c8ef87792450193e117976337b8527b49e8c03 PODFILE CHECKSUM: 0ccbb4f2406893c6e9f266dc1e7470dcd72885d2 -COCOAPODS: 1.12.1 +COCOAPODS: 1.13.0 From 205d6f2afa0b062b7bf04a9d2446b082cec89dcf Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Fri, 9 Feb 2024 11:39:25 +0000 Subject: [PATCH 5/5] fix: revert unnecessary iou changes --- src/libs/actions/IOU.ts | 41 +++++++---------------------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 7d669bc736eb..b83eb371e429 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -261,11 +261,7 @@ function clearMoneyRequest(transactionID: string) { // eslint-disable-next-line @typescript-eslint/naming-convention function setMoneyRequestAmount_temporaryForRefactor(transactionID: string, amount: number, currency: string, removeOriginalCurrency = false) { if (removeOriginalCurrency) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, { - amount, - currency, - originalCurrency: null, - }); + Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {amount, currency, originalCurrency: null}); return; } Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {amount, currency}); @@ -361,11 +357,7 @@ function resetMoneyRequestInfo(id = '') { function getReceiptError(receipt?: Receipt, filename?: string, isScanRequest = true): Errors | ErrorFields { return isEmptyObject(receipt) || !isScanRequest ? ErrorUtils.getMicroSecondOnyxError('iou.error.genericCreateFailureMessage') - : ErrorUtils.getMicroSecondOnyxErrorObject({ - error: CONST.IOU.RECEIPT_ERROR, - source: receipt.source?.toString() ?? '', - filename: filename ?? '', - }); + : ErrorUtils.getMicroSecondOnyxErrorObject({error: CONST.IOU.RECEIPT_ERROR, source: receipt.source?.toString() ?? '', filename: filename ?? ''}); } /** Return the object to update hasOutstandingChildRequest */ @@ -1571,13 +1563,7 @@ function createSplitsAndOnyxData( // Loop through participants creating individual chats, iouReports and reportActionIDs as needed const splitAmount = IOUUtils.calculateAmount(participants.length, amount, currency, false); - const splits: Split[] = [ - { - email: currentUserEmailForIOUSplit, - accountID: currentUserAccountID, - amount: IOUUtils.calculateAmount(participants.length, amount, currency, true), - }, - ]; + const splits: Split[] = [{email: currentUserEmailForIOUSplit, accountID: currentUserAccountID, amount: IOUUtils.calculateAmount(participants.length, amount, currency, true)}]; const hasMultipleParticipants = participants.length > 1; participants.forEach((participant) => { @@ -3593,17 +3579,9 @@ function setMoneyRequestParticipantsFromReport(transactionID: string, report: On const currentUserAccountID = currentUserPersonalDetails.accountID; const participants: Participant[] = ReportUtils.isPolicyExpenseChat(chatReport) ? [{reportID: chatReport?.reportID, isPolicyExpenseChat: true, selected: true}] - : (chatReport?.participantAccountIDs ?? []) - .filter((accountID) => currentUserAccountID !== accountID) - .map((accountID) => ({ - accountID, - selected: true, - })); - - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, { - participants, - participantsAutoAssigned: true, - }); + : (chatReport?.participantAccountIDs ?? []).filter((accountID) => currentUserAccountID !== accountID).map((accountID) => ({accountID, selected: true})); + + Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {participants, participantsAutoAssigned: true}); } /** Initialize money request info and navigate to the MoneyRequest page */ @@ -3691,12 +3669,7 @@ function navigateToNextPage(iou: OnyxEntry, iouType: string, repo const currentUserAccountID = currentUserPersonalDetails.accountID; const participants: Participant[] = ReportUtils.isPolicyExpenseChat(chatReport) ? [{reportID: chatReport?.reportID, isPolicyExpenseChat: true, selected: true}] - : (chatReport?.participantAccountIDs ?? []) - .filter((accountID) => currentUserAccountID !== accountID) - .map((accountID) => ({ - accountID, - selected: true, - })); + : (chatReport?.participantAccountIDs ?? []).filter((accountID) => currentUserAccountID !== accountID).map((accountID) => ({accountID, selected: true})); setMoneyRequestParticipants(participants); resetMoneyRequestCategory(); }