@@ -127,6 +127,7 @@ public function rollback(
127127 break ;
128128 }
129129
130+ // update the process request status to active
130131 $ processRequest = $ this ->newTask ->processRequest ;
131132 $ processRequest ->status = 'ACTIVE ' ;
132133 $ process = $ processRequest ->process ;
@@ -135,9 +136,12 @@ public function rollback(
135136 )->id ;
136137 $ processRequest ->saveOrFail ();
137138
139+ // update the current task status to closed
138140 $ currentTask ->status = 'CLOSED ' ;
139141 $ currentTask ->saveOrFail ();
140142
143+ $ this ->syncParentProcessStatus ($ processRequest );
144+
141145 return $ this ->newTask ;
142146 }
143147
@@ -209,4 +213,25 @@ private function addComment() : void
209213 'case_number ' => isset ($ this ->currentTask ->case_number ) ? $ this ->currentTask ->case_number : null ,
210214 ]);
211215 }
216+
217+ /**
218+ * When the rolled-back request is a subprocess, reactivate the parent request
219+ * and the parent's call activity tokens that were in error.
220+ */
221+ private function syncParentProcessStatus (ProcessRequest $ processRequest ): void
222+ {
223+ $ parentRequest = $ processRequest ->parentRequest ;
224+ if (!$ parentRequest ) {
225+ return ;
226+ }
227+
228+ if (in_array ($ parentRequest ->status , ['ERROR ' , 'FAILING ' ])) {
229+ $ parentRequest ->status = 'ACTIVE ' ;
230+ $ parentRequest ->saveOrFail ();
231+ }
232+
233+ ProcessRequestToken::where ('subprocess_request_id ' , $ processRequest ->id )
234+ ->whereIn ('status ' , ['ERROR ' , 'FAILING ' ])
235+ ->update (['status ' => 'ACTIVE ' ]);
236+ }
212237}
0 commit comments