Revealing the role of lattice distortions in the hydrogen-induced metal-insulator transition of SmNiO3