and FWIW, back on Big Sur, I'm also finding this JavaScript for Automation snippet reliable:
(() => {
"use strict";
const
se = Application("System Events"),
dockPreferences = se.dockPreferences;
return (
se.activate(),
dockPreferences.autohideMenuBar = (
delay(0.01),
!dockPreferences.autohideMenuBar()
)
);
})();
( click the Copy
icon at top right of the code block above )