I personally don’t trust keyboard switching information being correctly reported back to LO or any application. Moreover, I consider it a nuisance: I am no professional typist, consequently I look at the keyboard to know where characters are “hiding”. I am really dependent on my physical keyboard. For me, it is a “neutral” device for entering characters, I don’t want it to be linked to a language. Mechanical keys are where they are and don’t move if I select another disposition.
I prefer to customise the keyboard tables to add unusual characters I need frequently on third or fourth modifier levels.
When I type multilingual text, I always explicitly mark sequences to the relevant language through a custom paragraph or character style.
However, for mixed LTR-RTL text, this is not enough if the “boundary” characters are not letters. This is is your case with $ or (). Non-letter characters are considered directional-neutral in Unicode. It is likely they receive the direction property of the underlying paragraph. Thus they are considered as Persion and jump to their correct position for Persion layout.
The only solution is to create a strong directionality barrier between the language sequences. See @gabix’s answer.