{% for act in activities %}
{% set act_tasks = [] %}
{% for t in tasks %}
{% if t.activity_id|string == act._id|string %}
{% if act_tasks.append(t) %}{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% set no_act_tasks = [] %}
{% for t in tasks %}
{% if not t.activity_id %}
{% if no_act_tasks.append(t) %}{% endif %}
{% endif %}
{% endfor %}
{% if no_act_tasks %}