HDB summarizes the rules
here. To summarize the summary, practically anyone can inherit a HDB leasehold — even somebody living in Argentina — but whether the recipient can keep the leasehold depends on whether the recipient qualifies for one of the available HDB schemes. Otherwise it must be sold (exactly as Henry says), and the heir receives the net sales proceeds.
None of this really matters in the immediate case. If a leasehold owner wants to leave her unit to charity upon her demise, that’s her right. The existence of an essential occupier is a factor she can consider if she wishes, but that’s her choice. The charity then sells the leasehold, and the net sales proceeds go to the charity. If the essential occupier wishes to buy the leasehold from the charity, they reach an agreement, and the essential occupier qualifies under one of HDB’s schemes, that’s all fine, too.