diff --git a/lib/gitlab/import_export/project_tree_restorer.rb b/lib/gitlab/import_export/project_tree_restorer.rb
index accac5325f8e98d41507bb8d14944f637233f896..7cdba880a93f01519dcd785a82742708b8d1432a 100644
--- a/lib/gitlab/import_export/project_tree_restorer.rb
+++ b/lib/gitlab/import_export/project_tree_restorer.rb
@@ -120,8 +120,7 @@ module Gitlab
       end
 
       def parsed_relation_hash(relation_hash)
-        group_id = restored_project.group ? restored_project.group.id : nil
-        relation_hash.merge!('group_id' => group_id, 'project_id' => restored_project.id)
+        relation_hash.merge!('group_id' => restored_project.group.try(:id), 'project_id' => restored_project.id)
       end
     end
   end