Task - Sub Task.jpg

Built a Sub Task Grid: using a SQL table.
Built a Task Grid: using a SQL view and a Row Expander utilizing the Sub Task Grid.
Built a Task UX: Embedded the Task Grid.

I am trying to make best use of space/real-estate (so as much as possible can fit on 1 screen/view).

How do I:
1) Have the Sub Task Row “auto open” if there is indeed a Sub Task and stay “closed” if there is no Sub Task??

2) Remove the empty Row (that has no Sub Task – for entering a new Sub Task) and add a button to the Tool Bar for entering a new Sub Task/Row??

-Please see attached diagram