A mass will fall a certain distance, including the distance it compressed/stretched the spring. This total fall is proportional to the change in potential energy of the mass. At this point, all motion has stopped and the mass-spring system again has no internal kinetic energy, this energy being again transferred into the potential energy of the spring.
m*g*sin(theta)=k* [x(e)-x(0)]
2m*g*sin(theta)=k*[x(max)-x(0)]
x(0) is measured from the point where the spring just becomes taught.