Hide children of a task

Hello! I’m working on a custom filter to only display what the user wants to see. I found ‘onBeforeTaskDisplay’ to work fine, with returning false if the task is to be hidden.

However, when I hide a parent, the children are still visible. Is there a simple way to hide children of a task that is hidden?

I found the function isTaskVisible(task). I used it to ask if parent was visible, and if not, return false.