From 2d5fd5d5a0fe464b9968caceb595721ce515e8f0 Mon Sep 17 00:00:00 2001
From: Callum Knights <callum.knights@digital.cabinet-office.gov.uk>
Date: Thu, 30 May 2024 15:56:10 +0100
Subject: [PATCH] Adding review action from
 https://github.com/alphagov/whitehall/pull/9084 that I missed.

---
 app/controllers/admin/worldwide_offices_controller.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/app/controllers/admin/worldwide_offices_controller.rb b/app/controllers/admin/worldwide_offices_controller.rb
index 76518a78784..304a96489ff 100644
--- a/app/controllers/admin/worldwide_offices_controller.rb
+++ b/app/controllers/admin/worldwide_offices_controller.rb
@@ -21,8 +21,8 @@ def update
 
     update_params[:service_ids] ||= []
 
-    if update_params.dig(:contact_attributes, :contact_numbers_attributes)
-      update_params.dig(:contact_attributes, :contact_numbers_attributes).each do |_id, contact_number_attribute|
+    if (contact_numbers_attributes = update_params.dig(:contact_attributes, :contact_numbers_attributes))
+      contact_numbers_attributes.each do |_id, contact_number_attribute|
         contact_number_attribute[:_destroy] = true if contact_number_attribute[:label].empty? && contact_number_attribute[:number].empty?
       end
     end