Let us do all that work for you and just lean back...
Custom filters for Microsoft 365 Global Address List available
When creating a new sync connection (Source: Microsoft 365 GAL (internal users) v2), it is now possible to optionally define a filter for the desired directory users. A large number of filter expressions are available for configuration: https://help.sync.blue/hc/de/articles/14697613410450-How-can-I-only-sync-certain-GAL-users-filter-