@@ -609,7 +609,7 @@ type OptimisticModifiedExpenseReportAction = Pick<
609
609
| 'delegateAccountID'
610
610
> & { reportID ?: string } ;
611
611
612
- type BaseOptimisticMoneyRequestEntities = {
612
+ type OptimisticMoneyRequestEntities = {
613
613
iouReport : Report ;
614
614
type : ValueOf < typeof CONST . IOU . REPORT_ACTION_TYPE > ;
615
615
amount : number ;
@@ -627,10 +627,6 @@ type BaseOptimisticMoneyRequestEntities = {
627
627
linkedTrackedExpenseReportAction ?: ReportAction ;
628
628
} ;
629
629
630
- type OptimisticMoneyRequestEntities = BaseOptimisticMoneyRequestEntities & { shouldGenerateOptimisticTransactionThread ?: boolean } ;
631
- type OptimisticMoneyRequestEntitiesWithTransactionThreadFlag = BaseOptimisticMoneyRequestEntities & { shouldGenerateOptimisticTransactionThread : boolean } ;
632
- type OptimisticMoneyRequestEntitiesWithoutTransactionThreadFlag = BaseOptimisticMoneyRequestEntities ;
633
-
634
630
type OptimisticTaskReport = SetRequired <
635
631
Pick <
636
632
Report ,
@@ -3998,16 +3994,16 @@ const changeMoneyRequestHoldStatus = (reportAction: OnyxEntry<ReportAction>, sea
3998
3994
3999
3995
const transactionID = getOriginalMessage ( reportAction ) ?. IOUTransactionID ;
4000
3996
4001
- if ( ! transactionID ) {
4002
- Log . warn ( 'Missing transactionID during the change of the money request hold status' ) ;
3997
+ if ( ! transactionID || ! reportAction . childReportID ) {
3998
+ Log . warn ( 'Missing transactionID and reportAction.childReportID during the change of the money request hold status' ) ;
4003
3999
return ;
4004
4000
}
4005
4001
4006
4002
const transaction = allTransactions ?. [ `${ ONYXKEYS . COLLECTION . TRANSACTION } ${ transactionID } ` ] ?? ( { } as Transaction ) ;
4007
4003
const isOnHold = isOnHoldTransactionUtils ( transaction ) ;
4008
4004
const policy = allPolicies ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ moneyRequestReport . policyID } ` ] ?? null ;
4009
4005
4010
- if ( isOnHold && reportAction . childReportID ) {
4006
+ if ( isOnHold ) {
4011
4007
unholdRequest ( transactionID , reportAction . childReportID , searchHash ) ;
4012
4008
} else {
4013
4009
const activeRoute = encodeURIComponent ( Navigation . getActiveRoute ( ) ) ;
@@ -7348,7 +7344,6 @@ function buildTransactionThread(
7348
7344
reportAction : OnyxEntry < ReportAction | OptimisticIOUReportAction > ,
7349
7345
moneyRequestReport : OnyxEntry < Report > ,
7350
7346
existingTransactionThreadReportID ?: string ,
7351
- optimisticTransactionThreadReportID ?: string ,
7352
7347
) : OptimisticChatReport {
7353
7348
const participantAccountIDs = [ ...new Set ( [ currentUserAccountID , Number ( reportAction ?. actorAccountID ) ] ) ] . filter ( Boolean ) as number [ ] ;
7354
7349
const existingTransactionThreadReport = getReportOrDraftReport ( existingTransactionThreadReportID ) ;
@@ -7371,7 +7366,6 @@ function buildTransactionThread(
7371
7366
notificationPreference : CONST . REPORT . NOTIFICATION_PREFERENCE . HIDDEN ,
7372
7367
parentReportActionID : reportAction ?. reportActionID ,
7373
7368
parentReportID : moneyRequestReport ?. reportID ,
7374
- optimisticReportID : optimisticTransactionThreadReportID ,
7375
7369
} ) ;
7376
7370
}
7377
7371
@@ -7384,12 +7378,6 @@ function buildTransactionThread(
7384
7378
* 4. Transaction Thread linked to the IOU action via `parentReportActionID`
7385
7379
* 5. CREATED action for the Transaction Thread
7386
7380
*/
7387
- function buildOptimisticMoneyRequestEntities (
7388
- optimisticMoneyRequestEntities : OptimisticMoneyRequestEntitiesWithoutTransactionThreadFlag ,
7389
- ) : [ OptimisticCreatedReportAction , OptimisticCreatedReportAction , OptimisticIOUReportAction , OptimisticChatReport , OptimisticCreatedReportAction | null ] ;
7390
- function buildOptimisticMoneyRequestEntities (
7391
- optimisticMoneyRequestEntities : OptimisticMoneyRequestEntitiesWithTransactionThreadFlag ,
7392
- ) : [ OptimisticCreatedReportAction , OptimisticCreatedReportAction , OptimisticIOUReportAction , OptimisticChatReport | undefined , OptimisticCreatedReportAction | null ] ;
7393
7381
function buildOptimisticMoneyRequestEntities ( {
7394
7382
iouReport,
7395
7383
type,
@@ -7403,17 +7391,10 @@ function buildOptimisticMoneyRequestEntities({
7403
7391
isSettlingUp = false ,
7404
7392
isSendMoneyFlow = false ,
7405
7393
isOwnPolicyExpenseChat = false ,
7406
- shouldGenerateOptimisticTransactionThread = true ,
7407
7394
isPersonalTrackingExpense,
7408
7395
existingTransactionThreadReportID,
7409
7396
linkedTrackedExpenseReportAction,
7410
- } : OptimisticMoneyRequestEntities ) : [
7411
- OptimisticCreatedReportAction ,
7412
- OptimisticCreatedReportAction ,
7413
- OptimisticIOUReportAction ,
7414
- OptimisticChatReport | undefined ,
7415
- OptimisticCreatedReportAction | null ,
7416
- ] {
7397
+ } : OptimisticMoneyRequestEntities ) : [ OptimisticCreatedReportAction , OptimisticCreatedReportAction , OptimisticIOUReportAction , OptimisticChatReport , OptimisticCreatedReportAction | null ] {
7417
7398
const createdActionForChat = buildOptimisticCreatedReportAction ( payeeEmail ) ;
7418
7399
7419
7400
// The `CREATED` action must be optimistically generated before the IOU action so that it won't appear after the IOU action in the chat.
@@ -7438,11 +7419,11 @@ function buildOptimisticMoneyRequestEntities({
7438
7419
} ) ;
7439
7420
7440
7421
// Create optimistic transactionThread and the `CREATED` action for it, if existingTransactionThreadReportID is undefined
7441
- const transactionThread = shouldGenerateOptimisticTransactionThread ? buildTransactionThread ( iouAction , iouReport , existingTransactionThreadReportID ) : undefined ;
7442
- const createdActionForTransactionThread = ! ! existingTransactionThreadReportID || ! shouldGenerateOptimisticTransactionThread ? null : buildOptimisticCreatedReportAction ( payeeEmail ) ;
7422
+ const transactionThread = buildTransactionThread ( iouAction , iouReport , existingTransactionThreadReportID ) ;
7423
+ const createdActionForTransactionThread = existingTransactionThreadReportID ? null : buildOptimisticCreatedReportAction ( payeeEmail ) ;
7443
7424
7444
7425
// The IOU action and the transactionThread are co-dependent as parent-child, so we need to link them together
7445
- iouAction . childReportID = existingTransactionThreadReportID ?? transactionThread ? .reportID ;
7426
+ iouAction . childReportID = existingTransactionThreadReportID ?? transactionThread . reportID ;
7446
7427
7447
7428
return [ createdActionForChat , createdActionForIOUReport , iouAction , transactionThread , createdActionForTransactionThread ] ;
7448
7429
}
@@ -9231,12 +9212,12 @@ function getAllAncestorReportActionIDs(report: Report | null | undefined, includ
9231
9212
9232
9213
/**
9233
9214
* Get optimistic data of parent report action
9234
- * @param reportOrID The reportID of the report that is updated or the optimistic report on its own
9215
+ * @param reportID The reportID of the report that is updated
9235
9216
* @param lastVisibleActionCreated Last visible action created of the child report
9236
9217
* @param type The type of action in the child report
9237
9218
*/
9238
- function getOptimisticDataForParentReportAction ( reportOrID : Report | string | undefined , lastVisibleActionCreated : string , type : string ) : Array < OnyxUpdate | null > {
9239
- const report = typeof reportOrID === 'string' ? getReportOrDraftReport ( reportOrID ) : reportOrID ;
9219
+ function getOptimisticDataForParentReportAction ( reportID : string | undefined , lastVisibleActionCreated : string , type : string ) : Array < OnyxUpdate | null > {
9220
+ const report = getReportOrDraftReport ( reportID ) ;
9240
9221
9241
9222
if ( ! report || isEmptyObject ( report ) ) {
9242
9223
return [ ] ;
0 commit comments