Product and version: FileMaker Pro Advanced 17 & 16
OS and version: MacOS High Sierra 10.13.4
The problem arises if you have multiple windows showing the same layout and record, and the layout contains a filtered portal, and the filter takes into account the Get(WindowName) in order to provide different results in each window. If you use the "Refresh Portal" script step in order to update the filter in one window, the other window(s) will immediately update, showing the same records as the current window (which are not valid matches to the filter criteria in those other windows).
Workaround (if any)
Use "Refresh Window [ Flush cached join results ]" instead of "Refresh Portal"
Please see attached demo file.
Updated Clarification: The "Refresh Portal" script is not just refreshing the portal in all open windows, but it is refreshing the portal in all open windows using the filter as it is calculated in the context of the current window.