The core discussion begins in the mishna cited at Bava Batra 172b, which rules that if two men in one city are both named Yosef ben Shimon, neither can collect a promissory note against the other, nor can a third party collect against either of them, out of concern that a note belonging to one could have fallen and been found by the other or by someone else — yet each of them can still collect from others, a distinction the Gemara works to justify.
Bava Batra 173a shows that this is actually a three-way dispute among tannaim about whether a scribe may write a promissory note for a borrower before the lender is present, since that practice is what creates the risk that a found document reflects an unpaid loan rather than clear proof of debt — the case of two bearers of an identical name is simply the clearest test case for working out that underlying concern.
The same name-pair recurs in Gittin 24b, where Rava draws a parallel ruling about two men named Yosef ben Shimon living in the same city with respect to collecting debts from others, and Abaye challenges the parallel by comparing it to the law of a bill of divorce where two men share the same name, showing that the halachic consequences of a shared name are tested across multiple areas of monetary and family law using this identical example.
Bava Metzia 18 extends the discussion to divorce documents, ruling that a concern that a bill of divorce might belong to another man of the same name applies specifically where it has been established that two people named, for example, Yosef ben Shimon, are known to live in that particular city — meaning the designation is a stock legal illustration for the generic case of two identically named residents, not a statement about Yosef ben Shimon as a historically significant name per se.
The Meiri, commenting on Bava Batra 172b, treats the Yosef ben Shimon case as structurally identical to the case of Reuven ben Yehuda producing a note where the lender's name was omitted, confirming that the name pairing is used by the Rishonim purely as an illustrative example for the broader principle of identical names, interchangeable with other name pairs.
The Shulchan Arukh codifies this ruling in Shulchan Arukh, Choshen Mishpat 49:7, preserving the same two-Yosef-ben-Shimon scenario as the standard illustration for the law of identically named residents and a document containing a kinyan, while the Rema notes an internal tension in the reasoning behind the law.
Separately, Shabbat 103a discusses how an abbreviated form of a name such as Shimon can itself constitute a liable act of writing, showing that Shimon functions elsewhere in the Gemara as a generic, commonly used name for such illustrations, which is consistent with its use as half of the standard example name pair.
The sources concerning Yosef himself — his naming in Bereishit 30:23-24, Rashi's comment there that Rachel prophetically sought only one more son in Rashi (Bereishit 30:23-24), his renaming by Pharaoh in Bereishit 41:45, and the figure of Mashiach ben Yosef in Sukkah 52a — do not address the Gemara's legal use of 'Yosef ben Shimon' as a stock example for identically named litigants, and nothing in these passages bears on why that particular name pairing was chosen for the legal discussions in Bava Batra, Gittin, or Bava Metzia.
Likewise, Mesillat Yesharim 3:17-18, which discusses the darkness of night and errors of perception regarding physicality, has no bearing on the question of the significance of the name Yosef ben Shimon in these halachic discussions.