Fairly familiar usage, ordered by how recently I ate, with common implications:
"I have finished eating" -- I just now finished eating.
"I am done eating" -- I recently finished eating; I will not eat again soon.
"I have eaten" -- I ate earlier today; I am not hungry now.
This is a common misunderstanding. Your sentence mentions an action. That action seems to be in the past. The statement uses the present tense. Why?
Some verbs express action. Other verbs express state of being*. The verb "to have" expresses a state of being.
1) I saw the film.
2) I have seen the film.
3) I had seen the film.
In 1), the only verb is a past-tense action verb.
in 2), there are two verb words which form a single verb phrase. The "have" is a present-tense state-of-being verb. The "seen" is a verb without any tense but with the perfect aspect. This form does not express the action of the verb "to see". It expresses the result of that action.
I have seen the film. I possess a result of the action.
In 3), the "had" is a past-tense state-of-being verb.
The structure of 3) is rarely used on its own. Often, it's used to suggest that one thing is even further in the past than another:
4) I had seen the film when I read the book.
The action of "to read" is in the past. At the time of the action of "to read", my state of being included the result of the action of "to see". This suggests that that action of "to see" happened before the action of "to read".
_______________
* As far as I can tell, we use the phrase "state of being" because the word "condition" would be confusing. Verbs like "to be" and "to have" express a condition in the sense of "the way things are", rather than the sense of "something required for something else". We use the word "condition" in the second sense when discussing subordinate clauses, so we use "state of being" when discussing what a verb can express.
Best Answer
You want to use the past perfect tense (had eaten) when a past action occurs before (or leads up to) another past action. Therefore, #1 is correct. It means you ate chocolate in the past, but you ate it before you ate dinner (also in the past).
@Crosby is correct in saying we would not say #2. This is because the verb tense is not correct. The past perfect tense is not often used with the word when. When when means "at the same time" or "while," the sentence typically requires the simple past ...
The above sentence is only for example purposes. A better way to phrase this would be...
Or
Either way, the action was occurring at the same time or while you were eating dinner.
Hope this helps!