You can show the names of your shipping methods by using the query above and then pass the names to the function and filter out the handles with the same name.
Like This code:
const selectedShippingOption =
input?.cart?.deliveryGroups[0]?.selectedDeliveryOption;
const getPayMethod = input?.paymentMethods.find((method) => method?.name.toLocaleLowerCase().includes("cash on delivery"));
if (selectedShippingOption?.title?.toLocaleLowerCase().includes("express")) {
return {
operations: [
{
hide: {
paymentMethodId: getPayMethod?.id || '',
}
}
]
}
}