Take another look at the wiring in the light box. You’ll notice that the hot is being fed to the junction box via the WHITE conductor:
It looks like in the junction box that hot is transferred to the black conductor. Is that going to Box A? So is the hot in Box A the black?
So I think your concept is correct but the wire colors in your drawing may be off. Your drawing has the hot entering the j-box on the white. Unless you’ve re-wired the light fixture, that’s not correct. If the colors in your drawing or off, that may affect the logic so I would double-check those connections. It’s a bit hard to tell without the Romex in the j-box labeled. I’d meter those conductors in the j-box as well.

