Journal pages TODOs inbox

Hi, could someone please help me make this query also display TODOs and DOING tasks in the journal?

{:title [:b "Top-level Journal Blocks Without Links, Tags, or Being Referenced"]
:query [:find (pull ?block [*])
       :in $ %
       :where
       [?page :page/journal? true]
       [?block :block/parent ?page]
       (not [?block :block/refs])
       (not [?other :block/refs ?block])
       (not [?block :block/tags]) ; Exclude blocks with tags
       (not
         (descendant ?d ?block)
         (or-join [?d]
           [?d :block/refs]
           [?p :block/refs ?d]
         )
       )
     ]
:inputs [
 [
   [
     [descendant ?d ?b]
     [?d :block/parent ?b]
   ]
   [
     [descendant ?d ?b]
     [?d :block/parent ?parent]
     (descendant ?parent ?b)
   ]
 ]
]
}
#+END_QUERY

Thanks!

Welcome. Do you mean something like this? I added an or-join to say it either lacks a reference or it is a TODO or DOING task. This is because a task will always have a reference to the marker page (in this case TODO or DOING)

#+BEGIN_QUERY
{:title [:b "Top-level Journal Blocks Without Links, Tags, or Being Referenced"]
:query [:find (pull ?block [*])
       :in $ %
       :where
       [?page :page/journal? true]
       [?block :block/parent ?page]
       (or-join [?block]
         (and
           [?block :block/marker ?mark]
           [(contains? #{"TODO" "DOING"} ?mark)]
         )
         (not [?block :block/refs])
       )
       (not [?other :block/refs ?block])
       (not [?block :block/tags]) ; Exclude blocks with tags
       (not
         (descendant ?d ?block)
         (or-join [?d]
           [?d :block/refs]
           [?p :block/refs ?d]
         )
       )
     ]
:inputs [
 [
   [
     [descendant ?d ?b]
     [?d :block/parent ?b]
   ]
   [
     [descendant ?d ?b]
     [?d :block/parent ?parent]
     (descendant ?parent ?b)
   ]
 ]
]
}
#+END_QUERY