diff --git a/src/roster_window.py b/src/roster_window.py
index 65fc33bafd6424ff244cbf8b564d90fe8fea972e..52470a4f1f0360a06834e51f51a8c3448415e8f4 100644
--- a/src/roster_window.py
+++ b/src/roster_window.py
@@ -3577,9 +3577,9 @@ class RosterWindow:
 
 		type_ = model[titer][C_TYPE]
 		if type_ == 'group':
+			group = model[titer][C_JID].decode('utf-8')
 			child_model[child_iter][C_IMG] = gajim.interface.jabber_state_images[
 				'16']['opened']
-			group = model[titer][C_JID].decode('utf-8')
 			for account in accounts:
 				if group in gajim.groups[account]: # This account has this group
 					gajim.groups[account][group]['expand'] = True