Skip to content

Commit 4b22ec2

Browse files
authored
Merge pull request Expensify#64308 from nkdengineer/fix/63358
fix: nothing happens when clicking Remove hold
2 parents 748dfe1 + 331318f commit 4b22ec2

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

src/libs/API/parameters/ChangeTransactionsReportParams.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/**
22
* A map linking the optimistic MOVED_TRANSACTION or UNREPORTED_TRANSACTION reportActionID to the transactionID.
33
* If we're creating the transactionThread as part of moving the transaction, we should also send the optimistic
4-
* transactionThreadReportID and transactionThreadCreatedReportActionID
4+
* transactionThreadReportID and transactionThreadCreatedReportActionID. If the transaction is held before moving to selfDM,
5+
* we should also send the unholdReportActionID.
56
*/
67
type TransactionThreadInfo = {
78
movedReportActionID: string;
89
moneyRequestPreviewReportActionID: string;
910
transactionThreadReportID?: string;
1011
transactionThreadCreatedReportActionID?: string;
12+
unholdReportActionID?: string;
1113
selfDMReportID?: string;
1214
selfDMCreatedReportActionID?: string;
1315
};

src/libs/actions/Report.ts

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ import {
112112
buildOptimisticReportPreview,
113113
buildOptimisticRoomDescriptionUpdatedReportAction,
114114
buildOptimisticSelfDMReport,
115+
buildOptimisticUnHoldReportAction,
115116
buildOptimisticUnreportedTransactionAction,
116117
canUserPerformWriteAction as canUserPerformWriteActionReportUtils,
117118
findLastAccessedReport,
@@ -158,6 +159,7 @@ import {
158159
} from '@libs/ReportUtils';
159160
import shouldSkipDeepLinkNavigation from '@libs/shouldSkipDeepLinkNavigation';
160161
import playSound, {SOUNDS} from '@libs/Sound';
162+
import {isOnHold} from '@libs/TransactionUtils';
161163
import {addTrailingForwardSlash} from '@libs/Url';
162164
import Visibility from '@libs/Visibility';
163165
import type {FileObject} from '@pages/media/AttachmentModalScreen/types';
@@ -4815,7 +4817,7 @@ function deleteAppReport(reportID: string | undefined) {
48154817
{
48164818
onyxMethod: Onyx.METHOD.MERGE,
48174819
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
4818-
value: {reportID: CONST.REPORT.UNREPORTED_REPORT_ID},
4820+
value: {reportID: CONST.REPORT.UNREPORTED_REPORT_ID, comment: {hold: null}},
48194821
},
48204822
{
48214823
onyxMethod: Onyx.METHOD.MERGE,
@@ -4828,14 +4830,40 @@ function deleteAppReport(reportID: string | undefined) {
48284830
{
48294831
onyxMethod: Onyx.METHOD.MERGE,
48304832
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
4831-
value: {reportID: transaction?.reportID},
4833+
value: {reportID: transaction?.reportID, comment: {hold: transaction?.comment?.hold}},
48324834
},
48334835
{
48344836
onyxMethod: Onyx.METHOD.MERGE,
48354837
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`,
48364838
value: transactionViolations,
48374839
},
48384840
);
4841+
4842+
if (isOnHold(transaction)) {
4843+
const unHoldAction = buildOptimisticUnHoldReportAction();
4844+
optimisticData.push({
4845+
onyxMethod: Onyx.METHOD.MERGE,
4846+
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${childReportID}`,
4847+
value: {[unHoldAction.reportActionID]: unHoldAction},
4848+
});
4849+
4850+
successData.push({
4851+
onyxMethod: Onyx.METHOD.MERGE,
4852+
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${childReportID}`,
4853+
value: {[unHoldAction.reportActionID]: {pendingAction: null}},
4854+
});
4855+
4856+
failureData.push({
4857+
onyxMethod: Onyx.METHOD.MERGE,
4858+
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${childReportID}`,
4859+
value: {[unHoldAction.reportActionID]: null},
4860+
});
4861+
4862+
transactionIDToReportActionAndThreadData[transactionID] = {
4863+
...transactionIDToReportActionAndThreadData[transactionID],
4864+
unholdReportActionID: unHoldAction.reportActionID,
4865+
};
4866+
}
48394867
}
48404868

48414869
// 2. Move the report action to self DM
@@ -4919,6 +4947,7 @@ function deleteAppReport(reportID: string | undefined) {
49194947

49204948
if (transactionID) {
49214949
transactionIDToReportActionAndThreadData[transactionID] = {
4950+
...transactionIDToReportActionAndThreadData[transactionID],
49224951
moneyRequestPreviewReportActionID: newReportActionID,
49234952
movedReportActionID: unreportedAction?.reportActionID,
49244953
};

0 commit comments

Comments
 (0)