TLDR Imamat History: The Great Concealment
Imam Shams adDin Muhammad
During the Mongol Invasion, Shams adDin Muhammad was sent to Azerbaijan at the age of seven. The few Nizari groups left in Syria and Persia fell into strict secrecy, as they had done after the Fatimid schism. Many Nizaris saught refuge in Afghanistan and the Northern parts of India. For his own safety, the Imam took up embroidery and worked in Azerbaijan, secretly reorganizing the Ismaili Mission through travelling Dais and poets.
Imam Qasim Shah
Qasim Shah, with the help of Pir Shamsuddin Sabzwari (Pir Shams, but not Shams Tabriz: different Shams, same time), spread the Ismaili Mission beyond the borders of Iran. The Pir carried Qasim Shah's message through the Hindu Kush before eventually settling in Kashmir.
Imam Islam Shah
Islam Shah remained in hiding in Azerbaijan for his own safety, while Timor the Tartar marched across Iran to destroy what was left of the Ismailis. He sent Pir Sadruddin (a student of Pir Shams) to help spread the Ismaili Mission in Northern India.
Imam Muhammad ibn Islam Shah
While he remained in hiding, Muhammad ibn Islam Shah oversaw the spread of Ismailism in North India. Ismaili communities in India and East Africa (and later the Western Hemisphere) can all trace their traditions back to Pir Sadruddin's conversions at this time.
The Great Period of Concealment
We don't know much about the next 11 Imams except their names. The Ismaili community in the Middle East stayed under heavy secrecy due to the persecution from Mongols and Timor, but it grew quickly in India. There are mausoleums in Anjedan and Kahek (outside of Qom, Iran) that bear the names of some of these hidden Imams, along with some Indian-style inscriptions, showing the connection between distant communities.
Imam Abul Hassan Ali
While information about previous Imams has been lost to time, Abu Hassan Ali was preserved in public record. He served as a governor of the Kirman province of Iran, under the Zand Dynasty.
Imam Khalilullahi Ali
The previous three Imams had already been public figures to their local Ismaili communities, Khalilullahi Ali was also recognized by the Shah of Iran, Fath Ali Shah Qajar, who granted Ismailis passage through his borders in order to visit their Imam in Kahak. When the Imam was murdered by a rival mullah, the Shah arrested and sentenced those involved to a humiliating death before gifting his son, Shah Hassan Ali, two provinces and a hefty apology gift.