Stripe Dashboard search may need to filter a list of connected account or customer names while users type a query. Implement a function that performs flexible, case-insensitive name matching without changing the original display values.
A name matches when every query token appears as a substring of at least one token in the name. Matching must ignore case, punctuation, and repeated whitespace. Return matching names in their original order, including duplicates. If the query contains no searchable tokens, return all names.
Implement filter_names(names, query):
names is a list of strings.query is a string."Acme_Payments" becomes ['acme', 'payments'].def filter_names(names, query):