Hey shiny, how are you? I hope you are doing just fine!
Firstly you should know that after any preposition (such as ''for'', ''of'', etc...), you have to use a verb in the -ing form. The ''having'' used in the context given is considered to be a gerund form that refers to the state in which a person is at the moment and that which was affected by a condition or an experience in the past (the fact that she spent her time with you). This Grammar Pattern is what we call The ''Perfect Participle''.
* The ''Perfect Participle'' may be considered as a reduced form of explaining a certain situation that occurred (in the past) whose consequence is still ongoing. You can tell that it is the Perfect form of the Past Participle because it tells you the reason for the action that follows. If anything, it is used to indicate an action that happens long before (''she had spent her time with you'') the action in the main clause (''you thanked her for having done it'').
As regards your example, it would be the same as if you had said ''We thanked her for spending her time with us'', in which case the form used is that of the present participle (''spending''). However, you would hear people use the perfect participle more often, as in ''We thanked her for having spent her time with us''.
Here are some examples:
1) ''Having spent ten years in Italy, he could speak Italian fluently''. (After he had spent ten years in Italy, he could speak Italian fluently)
2) ''Having attended this course before, Tom knew what to expect.'' (Because Tom had attended this course before, he knew what to expect)
3) ''She saved me the bother of having come with a speech''. (perfect aspect)
4) ''Having read the book once before makes me more prepared. (perfect aspect)
5) ''He is ashamed of having been gambling all night. (perfect progressive aspect)
6) ''I was grounded for not having done my homework properly''.
Hope that helps!!! :)