Original query:

SELECT "main"."ID" "ID", "main"."name" "name", "main"."color" "color", "main"."location" "location", "main"."datefrom" "datefrom", "main"."dateto" "dateto", "main"."recurrence" "recurrence", "main"."interval" "interval", (COALESCE("invitations"."invited", 0)) "invited", (COALESCE("invitations"."attending", 0)) "attending", "follow"."ID" "follow"
FROM (SELECT "main"."ID" "ID", "main"."name" "name", "main"."color" "color", "main"."location" "location", "main"."datefrom" "datefrom", "main"."dateto" "dateto", "main"."recurrence" "recurrence", "main"."interval" "interval"
FROM "appointments" "main"
WHERE (((("main"."ownergroup" IN (1, 2, 11, 12) OR "main"."owneruser" = 1005 OR ("main"."owneruser" IS NULL AND "main"."ownergroup" IS NULL) OR "main"."assigneduser" = 1005) AND "main"."visibility" = '0')))
ORDER BY "main"."name", "main"."ID"
LIMIT 100) "main"
LEFT JOIN LATERAL (SELECT "ID" FROM "follows" WHERE ("creator" = 1005 AND "entity" = 'appointments' AND "index" = "main"."ID")) "follow" ON TRUE
LEFT JOIN LATERAL (SELECT (MIN(1) FILTER (WHERE ("email" = 'ben@coutu.de' OR "contact" = 1))) "invited", (MIN(1) FILTER (WHERE (("email" = 'ben@coutu.de' OR "contact" = 1) AND "flag" = 1))) "attending"
FROM "invitations" "inv"
WHERE ("appointment" = "main"."ID")) "invitations" ON TRUE
ORDER BY "main"."name", "main"."ID"

Prettified:

SELECT
  "main"."ID" AS ID,
  "main"."name" AS name,
  "main"."color" AS color,
  "main"."location" AS location,
  "main"."datefrom" AS datefrom,
  "main"."dateto" AS dateto,
  "main"."recurrence" AS recurrence,
  "main"."interval" AS interval,
  COALESCE("invitations"."invited", 0) AS invited,
  COALESCE("invitations"."attending", 0) AS attending,
  "follow"."ID" AS follow
FROM
  (
    SELECT
      "main"."ID" AS ID,
      "main"."name" AS name,
      "main"."color" AS color,
      "main"."location" AS location,
      "main"."datefrom" AS datefrom,
      "main"."dateto" AS dateto,
      "main"."recurrence" AS recurrence,
      "main"."interval" AS interval
    FROM
      "appointments" main
    WHERE
      (
        "main"."ownergroup" IN (1, 2, 11, 12) OR
        "main"."owneruser" = 1005 OR
        (
          "main"."owneruser" IS NULL AND
          "main"."ownergroup" IS NULL
        ) OR
        "main"."assigneduser" = 1005
      ) AND
      "main"."visibility" = '0'
    ORDER BY
      "main"."name",
      "main"."ID"
    LIMIT
      100
  ) main
  LEFT JOIN (
    SELECT
      "ID"
    FROM
      "follows"
    WHERE
      "creator" = 1005 AND
      "entity" = 'appointments' AND
      "index" = "main"."ID"
  ) follow ON true
  LEFT JOIN (
    SELECT
      min(1) AS invited,
      min(1) AS attending
    FROM
      "invitations" inv
    WHERE
      "appointment" = "main"."ID"
  ) invitations ON true
ORDER BY
  "main"."name",
  "main"."ID"