Hello Ellen! That's a REALLY good question!! I'll try to be concise:
Knowing when to use a gerund after an infinitive and when to use another infinitive depends on whether you want to stress the "real-ness" of the activity/experience or its "potentialness/ abstractness".
Gerunds are used to express this action-y-ness ('cause that's what a verb expresses) when it applies to a real world, something that could apply right now or habitually:
"I like eating ice cream."
The 'me liking the consumption of a cold dessert' is something happening right now. It's Not a what-if scenario or a conditional "were it the case that..." The act of eating is enjoyable to you, and we imagine that it is somehow part of your reality.
The infinitive is used to express an action that is not necessarily part of the world here and now. Maybe this IS a "what if / if that were the case" idea:
I like to eat ice cream.
The 'me that likes ice cream' does so in a very general way. Whether or not the consumption of cold dessert is part of your reality in a concrete way is not expressed.
The decision between gerund and infinitive largely depends on the first verb, in this case 'like'. Some verbs only allow a gerund to follow it, and some verbs only allow an infinitive. Others take both, such as "like". There are even verbs that distinguish whether or not the infinitive needs a ""to".
This is a really tiny and abstract distinction, and one most native speakers have never thought about or even heard of, even though it will sound strange to them if there is an error (even if they don't know why).
On the positive side: 99% of the time, you will be understood no matter what you say. You will acquire an intuition for the gerund vs infinitive as you continue to observe and use English.
Sadly, I don't have room here to attach websites here with verb lists, exercises or explanations, but there are plenty online. Search for "gerund infinitive..." or feel free contact me with any further questions.