I believe, in addition to the existing checks, it should also check -or $line -like 'Set-PoshPrompt*' which is an alternative way to set the theme instead of using Invoke-Expression (oh-my-posh --init ..., I believe that would be one possible fix to the issue discussed here
https://github.com/digitalcoyote/chocolatey-packages/blob/149528b716e4cbe88ecf3c420163ef3031650ac2/oh-my-posh/tools/chocolateyinstall.ps1#L20
I believe, in addition to the existing checks, it should also check
-or $line -like 'Set-PoshPrompt*'
which is an alternative way to set the theme instead of usingInvoke-Expression (oh-my-posh --init ...
, I believe that would be one possible fix to the issue discussed here