require(['jquery'], function($) {
    $(window).on('load', function() { // wait until Magento JS initializes
        $('.filter-options-item').each(function() {
            var $item = $(this);

            // Only collapse items that do not have a selected option
            if ($item.find('.filter-current').length === 0) {
                $item.removeClass('active').addClass('allow');      // replace active with allow
                $item.find('.filter-options-title')
                     .attr('aria-expanded', 'false');             // collapse title
            }
        });
    });
});


