Joseph couldn't control himself anymore in front of all of his attendants. He cried out, "Have everyone leave me!" So there wasn't anyone with Joseph when he told his brothers who he was.
References for Genesis 45:1
He sobbed so loudly that the Egyptians heard him. Everyone in Pharaoh's house heard about it.
Joseph said to his brothers, "I am Joseph! Is my father still alive?" But his brothers weren't able to answer him. They were too afraid of him.
Joseph said to his brothers, "Come close to me." So they did. Then he said, "I am your brother Joseph. I'm the one you sold into Egypt.
But don't be upset. And don't be angry with yourselves because you sold me here. God sent me ahead of you to save many lives.
"For two years now, there hasn't been enough food in the land. And for the next five years, people won't be plowing or gathering crops.