How to properly write sentence with double words
- It is okay, but can be potentially confusing/surprising for some people.
- In this particular sentence, you can do "I've been looking for this for a long time" or "For a long time, this is what I've been looking for".
This sort of thing is surprisingly common in English.
I couldn't decide if I had had a good time.
This is what I've been looking for for a long time. (Your original example.)
There's nothing wrong with these sentences, and they aren't grammatically incorrect. However, some people do find them infelicitous or awkward-sounding, so a simple rewording often fixes the problem.
I couldn't decide whether I really had a good time.
I've been looking for this for a long time.
You don't have to do this, but you can if you think it sounds better.