This has nothing to do with unitary executive. Immunity of the head of state derives from the concept of sovereign immunity, the government’s immunity from suit. In the U.S., it derives from the Crown’s immunity against suit.
“Functional immunity applies to both sitting and former heads of state; however, this immunity is available to such individuals solely with respect to acts performed in their official capacity (Fox 667).”
This notion is the core of the supreme court’s holding in this case.
The notion that former heads of state have some sort of immunity for official acts is also common in developed countries: https://oxcon.ouplaw.com/display/10.1093/law-mpeccol/law-mpe...
“Functional immunity applies to both sitting and former heads of state; however, this immunity is available to such individuals solely with respect to acts performed in their official capacity (Fox 667).”
This notion is the core of the supreme court’s holding in this case.