diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb index b6794729d..a5d825d55 100644 --- a/app/helpers/filters_helper.rb +++ b/app/helpers/filters_helper.rb @@ -116,7 +116,10 @@ module FiltersHelper user.support? || org.stock_owners.count > 1 || (org.holds_own_stock? && org.stock_owners.count.positive?) end - def logs_for_both_needstypes_present? + def logs_for_both_needstypes_present?(organisation) + return true if current_user.support? && organisation.blank? + return [1, 2].all? { |needstype| organisation.lettings_logs.visible.where(needstype:).count.positive? } if current_user.support? + [1, 2].all? { |needstype| current_user.lettings_logs.visible.where(needstype:).count.positive? } end diff --git a/app/views/logs/_log_filters.html.erb b/app/views/logs/_log_filters.html.erb index 3b531301c..589fb40ba 100644 --- a/app/views/logs/_log_filters.html.erb +++ b/app/views/logs/_log_filters.html.erb @@ -42,7 +42,7 @@ category: "status", } %> - <% if (current_user.support? || logs_for_both_needstypes_present?) && user_or_org_lettings_path? %> + <% if logs_for_both_needstypes_present?(@organisation) && user_or_org_lettings_path? %> <%= render partial: "filters/checkbox_filter", locals: { f:,