It’s too bad that there aren’t expression-like layer space transform equivalents in the scripting language, because what you really need here is toComp(). What I’d do is have the script temporarily add a point control to the selected layer, add a toComp() expression to it to calculate the layer’s left edge, harvest the result with the script, and delete the point control. The specifics depend on how you have things set up, but in general, that should work.