From 2d69584b654b6024656c3590f567cf6e8c06fb94 Mon Sep 17 00:00:00 2001 From: aaronskiba <71047780+aaronskiba@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:32:56 -0700 Subject: [PATCH] Prevent duplicate options in 'Select Guidance' - Prior to this commit, if current_user.org was also a @default_org, then @important_ggs would contain duplicate [org, ggs]. --- app/controllers/plans_controller.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 421514001a..277ce4a699 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -192,10 +192,8 @@ def show end @default_orgs = Org.default_orgs @all_ggs_grouped_by_org.each do |org, ggs| - @important_ggs << [org, ggs] if @default_orgs.include?(org) - - # If this is one of the already selected guidance groups its important! - @important_ggs << [org, ggs] if !(ggs & @selected_guidance_groups).empty? && !@important_ggs.include?([org, ggs]) + # @default_orgs and already selected guidance groups are important. + @important_ggs << [org, ggs] if (@default_orgs.include?(org) || !(ggs & @selected_guidance_groups).empty?) && !@important_ggs.include?([org, ggs]) end # Sort the rest by org name for the accordion