It's simpler than that. The change in potential energy of the falling mass increases both the kinetic energy of the flywheel and the falling mass. (They are connected by a string.) The energy used to increase the KE of the falling mass is energy not available to increase the KE of the flywheel. Doesn't matter what happens when the falling mass hits the ground.
See if you can derive the equation connecting the Δh of the falling mass with the resultant ω2