I'll explain from the beginning, for the benefit of anyone who doesn't understand the rule at all. The answer to your specific query is at the end. Despite/in spite of
are prepositions. After prepositions you need to use some form of noun phrase : For example : We went out for a walk in spite of the rain.
We arrived on time despite the heavy traffic.
A gerund is a "verbal noun", ie the form you use when you want a verb to take up the same syntactic position as a noun - for instance the subject. Compare... Chocolate makes you fat.
Smoking is bad for you
We have said that prepositions must be followed by nouns and that the gerund is the form of the verb that can substitute syntactically for a noun phrase. So eg after the preposition for
Thank you for the present
Thank you for helping
We've also said that in spite of / despite
are prepositions. So : We arrived on time despite the heavy traffic.
We arrived on time despite getting stuck in heavy traffic.
As you say, the subject of both verbs (the one in the main clause and the gerund) must be the same for this to happen - as in the example above : We arrived on time. We got stuck in heavy traffic.
If, on the other hand, the subject of the two verbs is different, then the "new" subject must be inserted. She paid for the meal. John told her not to.
She paid for the meal despite John telling her not to.
If the subject can be reduced to a pronoun then either the object or possessive pronoun can be used : John said that she paid for the meal despite his telling her not to.
John said that she insisted on paying despite him telling her not to.
So in your example, this would become... She paid for the meal despite me/my telling her not to.
And you are right. Grammatically, the pronoun can't be omitted here because of the change in subject. I don't know why the book says it can - it would result in a "dangling participle" clause. See this thread for more on those : I don't know what to title this one
There's a complication though, and I think this is what the book may have in mind. The construction with the preposition is rarely used - especially in a spoken context such as the one you quote. (It might be more likely in a formal, written text) We'd tend to avoid it by rephrasing : She paid for the meal although I told her not to.
She paid for the meal despite the fact that I told her not to.
And very often, if we did use the gerund, we might omit the pronoun because it sounds so stilted. Not everything that is said is 100% grammatical - the spontaneity of the communicative situations mean that slips often occur.
However, accepting that everyday speech often contains grammatical slips and building it into a coursebook as a productive model are two different things. I personally wouldn't teach my learners to use this - and I'm sure it would be considered wrong in the FCE exam if they used it in writing. in spoken English, you probably wouldn't notice, as the meaning is clear. But even so, rephrasing with "although" etc would still sound more natural.