I have what I thought would be a simple automation, but it's causing me huge headaches.
I trigger the creation of multiple tasks based on a transition. This all works nicely and my tasks are created without any issue. However, I want to extend this so that some of the tasks also have sub-tasks. For example, one task is for the maths on the project. The maths are split into development maths and final maths, both of which are sub-tasks under Maths.
The sub-tasks fail with "You can't add sub-tasks to epics. Sub-tasks are automatically associated with the same epic as their parent issues."

I originally tried this in a linear format with the sub-task created next and the Parent issue set to the variable created after the Task. The audit log is displaying this as the correct issue.

This was producing the error, so I changed it to branch after writing to the audit.

First with the branch defined as most recently created issue (i.e. the MathsTask). This still produced the same error, so I've changed it to branch on JQL of key = {{MathsTask}} but it still gives the error. After creating the branch, I have changed Parent issue for the sub-task to be {{MathsTask}} and Current Issue, although both still return the same error.
I have added an audit log immediately inside the branch that correctly writes the same MathsTask key using Branch Task is {{key}}.
I'm sure this is something simple. Can anyone help?