You can skip the second while loop.
If by the end of the first while loop all the elements of nums2 have been moved to nums1 then by default all the elements of nums1 will be in their correct place.