IMHO I would not upgrade the 22.04 image in place to 24.04 or higher:
If you need DKMS modules they are compiled tiht the running GCC, as the kernel does not change during a in-place upgrade but the GCC version does. THis migth result in strange behavior if even kernel moulds refuse to build.