Every U.S. state, and every U.S. district, commonwealth and territory has rules of professional conduct that follow the model of the ABA Model Rule of Professional Conduct (most have some jurisdiction specific variants of a few of the rules at least, such as the exceptions to the duty to confidentiality under Rule 1.6). Those rules set forth what to do, both in their language, in the official comments, in advisory opinions written by state ethics boards, and in adjudicated cases that have value as precedents. The pertinent rules are:
Rule 1.2 Scope of Representation and Allocation of Authority
Between Client and Lawyer
Rule 1.4 Communications
Rule 1.5 Fees
Rule 1.6 Confidentiality of Information
Rule 1.7 Conflict of Interest: Current Clients
Rule 1.8 Conflict of Interest: Current Clients: Specific Rules
Rule 1.9 Duties to Former Clients
Rule 1.10 Imputation of Conflicts of Interest: General Rule
Rule 1.11 Special Conflicts of Interest for Former and Current
Government Officers and Employees
Rule 1.12 Former Judge, Arbitrator, Mediator or Other Third-Party
Rule 1.13 Organization as Client
Rule 1.16 Declining or Terminating Representation
Rule 1.17 Sale of Law Practice
Rule 1.18 Duties to Prospective Client
Not all of the relevant rules apply to every situation. Roughly speaking, when a firm considers making a lateral hire, it does a full fledged conflict check comparing its current list of clients against every case that the lateral hire has enough of a connection to, in order to allow it to count as a potential conflict of interest given the attribution rules of Rule 1.10.
At that point, the hiring firm then analyzes potential conflicts to determine if they actually or potentially violate the rules, and if so, how the conflicts can be resolved.
The hiring firm can decline to hire, postpone a hire until a conflict ends (an associate attorney I know had a hiring delayed for about a year and a half due to that), withdraw from representing a conflicted client, obtain consent from the client that the hire represented to waive the conflict, or determine that the conflict doesn't violate the rule. If a client or former client disagrees there can be disqualification litigation in pending cases. Sometimes it is possible to "screen" a new hire from the case (something sometimes called a "Chinese wall"), but more often, it isn't.
Once the new hire is on board, new cases have to consider conflicts that the later hire brought with them, as new clients of the firm are evaluated. In a big law firm, you start every working day with a multi-page list of potential new clients that you have to flag for any conflicts that may be present based upon your list of past clients.
What you describe would probably present a conflict of interest that would cause the lawyer to be disqualified from representing the company (which might have to hire outside counsel that has no contact with the company lawyer, if the lawyer was hired).
In some areas of practice, as all of this suggests, lateral hiring is very ticklish and often not even worth attempting, in others (e.g. personal injury plaintiff's work or criminal defense) it is very rare for a lateral hire to cause of conflict of interest to arise. The risk of conflicts when larger firms are involved is one of the main reasons that "boutique" law firms that look like a single department within a large law firm have emerged as common in specialty areas like intellectual property.