You have a few things working against you:
- The PM Tab takes a while to load in script.
- There is no way to add custom attributes to the link between project and task.
if Task 5 is dependent on Task 3, you may want to consider nesting your tasks to make the code a little easier, or eliminate task 5 altogether.
You can autocomplete the workflow using item.performWorkflowTransitionByCustomID('CUSTOM_ID', 'COMMENTS')
When completing the tasks, you can write back to the details page of the Product, and the final task can then check the product to see if it is the last one to complete - if it is, transition the parent. You can use an integer for the number of tasks that need to be completed, and another to track the number of tasks completed. When completing a task increment the "completed tasks" integer and check to see if there are no more tasks remaining.