From MediaWiki 1.29, rows in the user_groups table may have an expiry date. When ug_expiry IS NOT NULL and strictly less than the current time, the row should be disregarded. This normally means adding a condition similar to
'ug_expiry IS NULL OR ug_expiry >= ' . $db->addQuotes( $db->timestamp() )
Some non-obsolete extensions query user_groups directly, and may need to be updated. See the subtasks of this task.