Understanding the magnetostructural transformation in ferh thin films