We will be going to upgrade Alteryx Server 2021.3.3.63061 to 2022.1.1.42 during this process embedded Mongo DB version will be automatically upgraded from 4.0 to older to 4.2 version.
Yes, the MongoDB will be migrated automatically at the end of the installation. Just make sure you have corrected any issues you find when running the pre-check app.
https://help.alteryx.com/20223/server/mongodb-schema-reference