I have scheduled builds for my app that I occasionally don't publish. These builds have an incremented version number but subsequent builds don't appear to use those version numbers as the max versions (see build 661fef97c0e7002274bcc8d0).
As a workaround, I've set the YAML to increment the max build number by 20, but it would be nice if this script got the "true" maximum version code from all AABs that are in the google play repository, regardless of whether or not they're published or even in a track.