Yeah so the idea would be that the user still uses the same string input but instead of the filter being <notebook name>,<notebook name>,<notebook name> you could mix and match so you could instead have <notebook name>,<notebook ID>,<notebook name>.
These would all be converted into IDs, if a filter item matches an ID of an existing notebook we stop there, if it doesn't we treat it like a name and include all notebook IDs with matching names (this preserves the existing behaviour). The same notebook ancestor matching behaviour would exist where you climb up the links until you hit a top level notebook.
Then when filtering notes we just test the note's notebook ID again the list as opposed to converting the notebook ID into a name and testing that.
With these specific proposed changes, the current filters would be entirely unchanged since the only change is how the data is processed, but that doesn't need to be stored or anything, plus the current behaviour should be entirely unchanged. (Afaict performance should be pretty much identical too, most people aren't going to have hundreds of notebooks with the same name)