                                (r/to-epoch-time)
                                (r/mul 1000)
                                (r/round))
-              unread-thread? (r/or (r/not (r/contains (r/keys read-items-map) (r/get-field row :uuid)))
-                                   (r/gt (-> last-activity-at (r/iso8601) (r/to-epoch-time) (r/mul 1000) (r/round))
-                                         (-> (r/get-field row :uuid)
-                                          (as-> x (r/get-field read-items-map x))
-                                          (r/iso8601)
-                                          (r/to-epoch-time)
-                                          (r/mul 1000)
-                                          (r/round))))
-              unread-with-cap? (r/and unread-thread?
+              unread-activity? (r/or (r/not (r/contains (r/keys read-items-map) (r/get-field row :uuid)))
+                                     (r/gt (-> last-activity-at (r/iso8601) (r/to-epoch-time) (r/mul 1000) (r/round))
+                                           (-> (r/get-field row :uuid)
+                                            (as-> x (r/get-field read-items-map x))
+                                            (r/iso8601)
+                                            (r/to-epoch-time)
+                                            (r/mul 1000)
+                                            (r/round))))
+              unread-with-cap? (r/and unread-activity?
                                       (r/gt (-> last-activity-at (r/iso8601) (r/to-epoch-time) (r/mul 1000) (r/round))
                                             (-> (r/now) (r/to-epoch-time) (r/mul 1000) (r/round) (r/sub unread-cap-ms))))]
           {;; Date of the last added comment on this thread

                                     (r/to-epoch-time)
                                     (r/mul 1000)
                                     (r/round))
                    unread-entry? (r/not (r/contains (r/keys read-items-map) (r/get-field post-row :uuid)))]
                {;; Date of the last added comment on this thread
                 :last-activity-at last-activity-at
                 :last-read-at (r/branch unread-entry?
                                nil
                                (r/get-field read-items-map (r/get-field post-row :uuid)))
                 :sort-value (r/branch unread-entry?
                               ;; If the item is unread and was published in the cap window
                               ;; let's add the cap window to the publish timestamp so it will sort before the read items
                               (r/add sort-value-base unread-cap-ms)
                               ;; The timestamp in seconds
                               sort-value-base)
                })))
            ;; Filter out:
            (r/filter query (r/fn [row]

                          (r/coerce-to :array))
           ;; FIXME: debug
           ; :debug {:unread-with-cap unread-with-cap?
           ;         :unread-activity unread-activity?}
          })))
       ;; Filter by user-visibility
       (r/filter query (r/fn [row]
