@Julio César González Montaño Thanks for reaching out.
AAD group based licensing only supports security groups (on cloud, or synced from on-prem), and Microsoft 365 groups that have securityEnabled=TRUE.
It has to be assigned or dynamic USER security group.
So you can filter out non security and device group from your list.
Also here is a known limitation of AAD group based licensing : https://learn.microsoft.com/en-us/azure/active-directory/enterprise-users/licensing-group-advanced#limitations-and-known-issues
-----------------------------------------------------------------------------------------------------------------
If the suggested response helped you resolve your issue, please do not forget to accept the response as Answer and "Up-Vote" for the answer that helped you for benefit of the community.