                                (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

        order-fn (if (= order :desc) r/desc r/asc)
        read-items-map (r/coerce-to (zipmap (map :item-id read-items) (map :read-at read-items)) :object)
        unread-cap-ms (if (zero? config/unread-cap-days)
                        (* 60 60 24 365 50 1000) ;; 50 years cap
                        (* 60 60 24 config/unread-cap-days 1000))]
    (db-common/with-timeout db-common/default-timeout
      (as-> (r/table table-name) query

                          (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]
