أحسن الله إليكم In the Hadith "إذا رأيتموه فصوموا وإذا رأيتموه فأفطروا….." what is the “ه” referring to? Does it mean the moon? If it means the moon then shouldn’t it be "ها" since it’s a feminine word? Can you please clarify?

Ustadh AbdulAziz al-Haqqan
It refers to the hilal, the crescent, the crescent of Ramadan in the first part and the crescent of Shawwal in the second. Hilal is a masculine word in Arabic, so the masculine pronoun is the correct one, and the narration of Abu Hurayrah in Muslim states it openly, if you see the hilal then fast, and when you see it then break your fast.