@@ -240,6 +240,7 @@ import {
240240 hasViolation ,
241241 hasWarningTypeViolation ,
242242 isCardTransaction as isCardTransactionTransactionUtils ,
243+ isDemoTransaction ,
243244 isDistanceRequest ,
244245 isExpensifyCardTransaction ,
245246 isFetchingWaypointsFromServer ,
@@ -372,6 +373,7 @@ type BuildOptimisticIOUReportActionParams = {
372373 created ?: string ;
373374 linkedExpenseReportAction ?: OnyxEntry < ReportAction > ;
374375 isPersonalTrackingExpense ?: boolean ;
376+ reportActionID ?: string ;
375377} ;
376378
377379type OptimisticIOUReportAction = Pick <
@@ -2500,13 +2502,17 @@ function canDeleteCardTransactionByLiabilityType(transaction: OnyxEntry<Transact
25002502 * Can only delete if the author is this user and the action is an ADD_COMMENT action or an IOU action in an unsettled report, or if the user is a
25012503 * policy admin
25022504 */
2503- function canDeleteReportAction ( reportAction : OnyxInputOrEntry < ReportAction > , reportID : string | undefined , iouTransaction ? : OnyxEntry < Transaction > ) : boolean {
2505+ function canDeleteReportAction ( reportAction : OnyxInputOrEntry < ReportAction > , reportID : string | undefined , transaction : OnyxEntry < Transaction > | undefined ) : boolean {
25042506 const report = getReportOrDraftReport ( reportID ) ;
25052507 const isActionOwner = reportAction ?. actorAccountID === currentUserAccountID ;
25062508 const policy = allPolicies ?. [ `${ ONYXKEYS . COLLECTION . POLICY } ${ report ?. policyID } ` ] ?? null ;
25072509
2510+ if ( isDemoTransaction ( transaction ) ) {
2511+ return true ;
2512+ }
2513+
25082514 if ( isMoneyRequestAction ( reportAction ) ) {
2509- const isCardTransactionCanBeDeleted = canDeleteCardTransactionByLiabilityType ( iouTransaction ) ;
2515+ const isCardTransactionCanBeDeleted = canDeleteCardTransactionByLiabilityType ( transaction ) ;
25102516 // For now, users cannot delete split actions
25112517 const isSplitAction = getOriginalMessage ( reportAction ) ?. type === CONST . IOU . REPORT_ACTION_TYPE . SPLIT ;
25122518
@@ -6247,6 +6253,7 @@ function buildOptimisticIOUReportAction(params: BuildOptimisticIOUReportActionPa
62476253 created = DateUtils . getDBTime ( ) ,
62486254 linkedExpenseReportAction,
62496255 isPersonalTrackingExpense = false ,
6256+ reportActionID,
62506257 } = params ;
62516258
62526259 const IOUReportID = isPersonalTrackingExpense ? undefined : iouReportID || generateReportID ( ) ;
@@ -6306,7 +6313,7 @@ function buildOptimisticIOUReportAction(params: BuildOptimisticIOUReportActionPa
63066313 automatic : false ,
63076314 isAttachmentOnly : false ,
63086315 originalMessage,
6309- reportActionID : rand64 ( ) ,
6316+ reportActionID : reportActionID ?? rand64 ( ) ,
63106317 shouldShow : true ,
63116318 created,
63126319 pendingAction : CONST . RED_BRICK_ROAD_PENDING_ACTION . ADD ,
0 commit comments