It will depend on the specific facts
Let's define a few terms:
- Company A was the original company,
- Company B is the current company (which may be the same as Company A or a different company),
- Owner A was (and may still be) the shareholders of Company A,
- Owner B are the shareholders of Company B,
- the Business is the enterprise that was carried on by Company A and is now carried on by Company B,
- the Domain is the licence from the Domain Name Registrar which may be owned by any of the above (except the Business because it's not a legal person).
Owner A and Owner B might be an individual natural person or an individual company or a group of natural persons/companies.
Both the Business and the Domain are assets just like a car or office furniture that can be bought and sold independently of the Company that owns them.
- Who owned the domain registration?
This might have been Company A in its own right or Owner A in which case Company A would be using it under some sort of licence, probably an implicit and undocumented one.
- Was Company A or the Business bought?
Both are possibilities, see Is it possible to keep assets from being taken when a company is bought by another?
If the company was sold the Company B is Company A. If the business was sold then Company A is different from Company B.
Company A owned the Domain and Company A was sold
Company A/B continues to own the domain. There is no room for dispute here.
Owner A owned the Domain and Company A was sold
Owner A continues to own the domain but Company A/B retains the benefit of the licence. There is scope for dispute over the terms and duration of that licence.
Company A owned the Domain and the Business was sold
The terms of the contract would need to be consulted to determine whether the Domain was part of the assets that comprised the Business. There is scope for dispute here, see the Peanut Butter Wars over whether trade dress was part of the business (spoiler, it was).
If it was, then Company B owns it even if it is legally still held by Company A - they would be holding it on trust for Company B pending legal transfer. There is no scope for dispute here.
If it wasn't, then one has to ask how has Company B been using it for 7 years? There is scope for dispute here. It's possible that they were using it under a licence, if so, what are the terms? It's also possible they have a right to it as a result of other IP they own, usually a trademark.
Owner A owned the Domain and the Business was sold
The terms of the contract would need to be consulted to determine whether the licence in the Domain was part of the assets that comprised the Business. There is scope for dispute here.
If it was then Company B retains the benefit of the licence. There is scope for dispute over the terms and duration of that licence.
If it wasn't, then one has to ask how has Company B been using it for 7 years? There is scope for dispute here. It's possible that they were using it under a licence, if so, what are the terms? It's also possible they have a right to it as a result of other IP they own, usually a trademark.