How to use a DO_WHILE operator to update input parameters?

You can use an INLINE task to update the loop’s input parameters for subsequent iterations.

I’m still struggling with this. I am trying to do a do_while loop over a sub workflow task. I want to run the sub workflow max 3 times and break out of the loop once the subwf finishes with status completed. But I can’t quite figure out how to reference the subwf status. Here is my json

{
  "createTime": 1762974155151,
  "updateTime": 1762976621184,
  "name": "_joe_loop_test",
  "description": "Parent workflow to run 'newscast' up to 3 times.",
  "version": 1,
  "tasks": [
    {
      "name": "retry_newscast_loop",
      "taskReferenceName": "loop",
      "inputParameters": {
        "max": 3,
        "keepLastN": 4,
        "status": "${workflow.variables.status}"
      },
      "type": "DO_WHILE",
      "decisionCases": {},
      "defaultCase": [],
      "forkTasks": [],
      "startDelay": 0,
      "joinOn": [],
      "optional": false,
      "defaultExclusiveJoinTask": [],
      "asyncComplete": false,
      "loopCondition": "(function () {\n  if ($.subwf['status'] === 'COMPLETED'){ return true; }\n  \n  if ($.loop['iteration'] < $.max) {\n    return true;\n  }\n  return false;\n})();",
      "loopOver": [
        {
          "name": "sub_workflow",
          "taskReferenceName": "subwf",
          "inputParameters": {},
          "type": "SUB_WORKFLOW",
          "decisionCases": {},
          "defaultCase": [],
          "forkTasks": [],
          "startDelay": 0,
          "subWorkflowParam": {
            "name": "_chaos_monkey_workflow"
          },
          "joinOn": [],
          "optional": true,
          "defaultExclusiveJoinTask": [],
          "asyncComplete": false,
          "loopOver": [],
          "onStateChange": {},
          "permissive": false
        },
        {
          "name": "set_variable",
          "taskReferenceName": "setStatus",
          "inputParameters": {
            "status": "${subwf.status}"
          },
          "type": "SET_VARIABLE",
          "decisionCases": {},
          "defaultCase": [],
          "forkTasks": [],
          "startDelay": 0,
          "joinOn": [],
          "optional": false,
          "defaultExclusiveJoinTask": [],
          "asyncComplete": false,
          "loopOver": [],
          "onStateChange": {},
          "permissive": false
        },
        {
          "name": "wait-for-x-seconds",
          "taskReferenceName": "wait-for-x-seconds_ref",
          "inputParameters": {
            "seconds": 3
          },
          "type": "SIMPLE",
          "decisionCases": {},
          "defaultCase": [],
          "forkTasks": [],
          "startDelay": 0,
          "joinOn": [],
          "optional": false,
          "defaultExclusiveJoinTask": [],
          "asyncComplete": false,
          "loopOver": [],
          "onStateChange": {},
          "permissive": false
        }
      ],
      "evaluatorType": "graaljs",
      "onStateChange": {},
      "permissive": false
    }
  ],
  "inputParameters": [],
  "outputParameters": {},
  "failureWorkflow": "",
  "schemaVersion": 2,
  "restartable": true,
  "workflowStatusListenerEnabled": false,
  "ownerEmail": "jkampschmidt@npr.org",
  "timeoutPolicy": "ALERT_ONLY",
  "timeoutSeconds": 0,
  "variables": {},
  "inputTemplate": {},
  "enforceSchema": true
}