diff --git a/bin/database.py b/bin/database.py
index 0dbd90ba130e86675f9284c76712264c9ec1b068..375c4b76f37c5a23d88eae9521e5f7152a4b3a68 100755
--- a/bin/database.py
+++ b/bin/database.py
@@ -1344,12 +1344,11 @@ def upgrade_to_41():
 
 def upgrade_to_42_closure(cont, cont_name):
     archived = cont.pop('archived')
+    update = {'$unset': {'archived': True}}
     if archived:
         cont['tags'] = cont.get('tags', []) + ['hidden']
-    config.db[cont_name].update_one({'_id': cont['_id']}, {
-                                        '$set': {'tags': cont['tags']},
-                                        '$unset': {'archived': True}
-                                    })
+        update['$set'] = {'tags': cont['tags']}
+    config.db[cont_name].update_one({'_id': cont['_id']}, update)
     return True
 
 def upgrade_to_42():
diff --git a/tests/integration_tests/python/test_upgrades.py b/tests/integration_tests/python/test_upgrades.py
index 748986e589079a5d11b8bd181f899d14553b0e94..4d0b51a0593817ac7678d0e8d5d5c84f1d8f3259 100644
--- a/tests/integration_tests/python/test_upgrades.py
+++ b/tests/integration_tests/python/test_upgrades.py
@@ -16,13 +16,19 @@ def database(mocker):
 def test_42(data_builder, api_db, as_admin, database):
     # Mimic old-style archived flag
     session = data_builder.create_session()
+    session2 = data_builder.create_session()
     api_db.sessions.update_one({'_id': bson.ObjectId(session)}, {'$set': {'archived': True}})
+    api_db.sessions.update_one({'_id': bson.ObjectId(session2)}, {'$set': {'archived': False}})
 
     # Verfiy archived session is not hidden anymore
-    assert session in [s['_id'] for s in as_admin.get('/sessions').json()]
+    assert session  in [s['_id'] for s in as_admin.get('/sessions').json()]
 
     # Verify upgrade creates new-style hidden tag
     database.upgrade_to_42()
     session_data = as_admin.get('/sessions/' + session).json()
     assert 'archived' not in session_data
     assert 'hidden' in session_data['tags']
+
+    # Verify archived was removed when false as well
+    session_data = as_admin.get('/sessions/' + session2).json()
+    assert 'archived' not in session_data