Read the release notes and replicaset upgrade for each version.

MongoDB 5.0+ requires avx feature set on x86_64 architecture.
Ubuntu 18.04 will only support up to MongoDB version 6.0. Ubuntu 22.04 will then support 6.0.4 through to MongoDB 8.0.
If using the MongoDB repos for apt, expired gpg certificates are likely to be encountered and implicitly trusting them will be needed.
If following correct procedures “downtime” is limited to the time it takes to step down and elect a new primary.
One primary concern is that all client applications are using up to date drivers!