You can write had had when the having happened before a later past moment that your own sentence supplies, and you can point to that later moment in the sentence: She had had that car since college when it broke down. The first had is just the auxiliary, the second the main verb's participle.
Your sentence describes an experience before another past moment
You're telling a story about yesterday and need to mention something earlier than that: By lunchtime I had had three meetings already. Your sentence works because lunchtime is the past moment, and the meetings happened before it.
You're reporting what someone said about an earlier experience. Their direct words were I had a bad dream before I woke up, and your reported version becomes She said she had had a bad dream before she woke up. The reporting verb said pushes the experience one step further back, so had had fits.
You're explaining how someone felt at a past moment because of something earlier: He felt marvelous because he had had a good night's sleep. The feeling happened last night; the good sleep came before it, so the earlier event takes had had.
You're describing trouble that built up before another past point: We had had problems with the washing machine for weeks before we finally replaced it. The weeks of trouble are the background, and the replacing is the later past event your sentence supplies.
One contrast to keep you out of trouble. If the main verb isn't have, there's no doubled form at all: She had taken the keys before I arrived is past perfect, but only have as the main verb produces had had. And don't reach for had had unless the earlier experience really happened before a second past point.
One boundary to keep in mind: had had is strictly a past form, so it only works when the having happened before a later past moment. If the experience belongs to now or this week, the past perfect doesn't fit, and the present perfect takes over instead: I've had a busy week says the week is still your current one, while I had had a busy week only makes sense when you're looking back at it from another point in the past.
When there's no earlier past event to point back to
Use had had only when your sentence points to a later past moment that the having happened before. If there's no such anchor, the form sounds wrong even though grammar books list it.
Your sentence has no second past event: I had had a long day. As a standalone sentence this leaves the reader waiting for a moment to anchor it. Add the later past point and it works: I had had a long day, so I went to bed early.
You're talking about now or this week: I've had a busy week. The present perfect fits because your reference point is the present. Swap in had had and you're claiming some past anchor the sentence never supplies.
The exception to watch: a past perfect can anchor to a specific past time rather than another action, so By midnight she had had enough is fine. Midnight is the past point. What's missing in the wrong versions isn't a second clause, it's any past anchor at all.
So run the test before you write it: can you point to the later past moment in your own sentence? If you can, had had fits. If you can't, use the simple past had or the present perfect, and save had had for when the timeline genuinely doubles back.