So the error says that you are trying to use the name when the roles return null for some reason. So is there a user that doesn't have a role in the database assigned? Because first() returns null if there are no roles for a user.
show works because that user has a role, but when you list all the users it can fail on any user that doesn't have a role.
So you can query the users that have at least one role maybe
$users = User::whereHas('roles')->with('roles')->get();