Fixed assumptions in tagsToGroups function for notes