The basic idea is to tie the filter data to the current user (or even to a single page visit) and reset it whenever the page is opened. You can model FilterSession and FilterId as persistent entities and link them to System.User, so each user only ever works with their own filter data.
On the page’s On Page Load microflow, you simply clean up first: find any existing FilterSession records for the current user and delete them together with their related FilterId rows. If you want, you can immediately create a new, empty FilterSession so the page always starts in a known, clean state.
When the user types something like 1,2,3 into the filter field and clicks an Apply button (or triggers an On Change action), a microflow parses that string, clears the old FilterId entries for the current session, and creates new ones for each parsed ID. The Data Grid 2 then uses an XPath constraint through the association to only show items that match those IDs.
With this setup, nothing is left behind in the database because the data is cleared every time the page is entered. The only thing to be aware of is that if the same user opens the page in multiple browser tabs, the filter data could interfere with itself. If that’s a real concern, you can extend FilterSession with a simple page-specific identifier so each tab keeps its own separate filter state.