The recommended and tested procedure is to upgrade the MongoDB version by upgrading sequentially. Hence, for you the upgrade sequence would be 4.2 → 4.4 → 5.0 → 6.0 → 7.0.
Kindly go through below thread to understand more on this.
Let me know in case of any queries/issues, would be happy to help you!