This M.Y. answer states that one can daven Mincha until the stars appear. This answer states that it is also the earliest time to daven Ma'ariv.
Someone enters a shul which gets a late start on Mincha and they daven during twi-light. They will daven Ma'ariv immediately after Mincha. The person daven's the mincha silent Shmoneh Esreh (weekday). As soon as he finishes, he remembers that he had already davened mincha earlier in the day.
Since he davened the 2nd mincha at the time that's eligible for Ma'ariv, and it's the same (weekday) Shmoneh Esreh, does he need to say it again, or can this accidental extra Shmoneh Esreh count for Ma'ariv?
I mentioned here that he is davening with a congregation, so, perhaps there is a specific halacha that he needs to daven Shmoneh Esreh with the congregation. Is there any difference in halacha if he were davening at home and the same scenario occurred?