Theoretical study of the influence of hydrides on the performance of Mg and y photocathodes