How this kind of sentence is built with a noun phrase (gerund):
The gerund phrase here is: telling me to leave.
"Telling me to leave [noun phrase] is not the best idea they had that night."
English often uses gerund phrases: playing tennis, singing songs, sailing boats.
All those can be used as subjects in sentences or objects in sentences.
These gerund phrases can be placed after the direct object of certain transitive verbs and listen to [someone] which is intransitive:
- listen to someone [+ noun phrase], listen to someone singing in the night
- find someone [+ noun phrase], find someone sitting around and doing nothing
describe someone [+ noun phrase], describe someone studying their Latin
Listening to someone [I don't know] suddenly telling me to leave was not fun.
Although tell is not technically "wrong" (listen to someone tell me to leave), using the gerund fulfills the idea of an activity as opposed to a one-time action:
- I don't want to listen to someone tell me to leave (again).
If "tell" is used or another verb that is not a gerund, it sounds like a one-time action.
- I don't want to see anyone play tennis (today).
Compared to:
- I don't want to see anyone playing tennis (the activity)