I remind you that "HAMAS" is an an acronym of its official name, Harakat al-Muqawama al-Islamiya, which means "'Islamic Resistance Movement". It is not a terrorist group like Al Qaeda, Al Nusra or ISIS. It does nopt want to conquer or spread Islam or create a Caliphate. It sis a movement to resist the illegal occupation of Palestine by Israel.
They have no terrorist aims outside of that movement goal. In their latest Charter (2017) HAMAS even acknowledges a two-state solution and Israel's proper territory (according to UN Resolution 242).
So they are a resistance movement similar to the Italian Partisans (Partigiani d'Italia) the French Resistance (La Résistance) and even the German White Rose (Weiße Rose) who "resisted" the Nazis.
In short, if Israel ended the occupation, there would be no more HAMAS.