<select id="add-filter-select" multiple>
    <%
        var uniqueGroups = [];
        $.each(groups, function(i, el){
            if($.inArray(el, uniqueGroups) === -1) uniqueGroups.push(el);
        });
    %>
    <% uniqueGroups.forEach((group) => { %>
        <optgroup label="<%= group %>">
            <% Object.keys(filters).forEach((filterKey) => { %>
                <% if (filters[filterKey].group === group) { %>
                    <option value="<%= filterKey %>" <% if (filters[filterKey].enabled) { %>selected<% } %>>
                        <%= filters[filterKey].label %>
                    </option>
                    <% } %>
            <% }); %>
        </optgroup>
    <% }); %>
</select>