Staff at Kozee Sleep, which supplied retailers including John Lewis and Next, were paid as little as Â£10 a day.
Company owner Mohammed Rafiq and employees Mohammed Patel and Mohammed Dadhiwala are accused of conspiracy to traffic individuals within the UK.
All three men deny any wrongdoing in their trial at Leeds Crown Court.
The court heard that an investigation was launched into Kozee Sleep, based in Dewsbury, and its subsidiary Layzee Sleep, in Batley, after two Hungarians, Janos Orsos and Ferenc Illes, were arrested over human trafficking allegations.
The jury was told large numbers of Hungarian men were employed at both factories at a time when the business was in financial trouble.
Christopher Tehrani QC, prosecuting, told said: "Kozee Sleep provided some of the UK's largest retailers with beds and mattresses either directly or through intermediary companies.
"These companies included Next Plc, the John Lewis Partnership and Dunelm Mill.
"As part of the contract, Kozee Sleep was required to adhere to each company's policies re ethical trading, which included how they treated persons who worked on their premises."
Mr Tehrani said the firms carried out regular ethical audits before May 2014, but added: "Nothing untoward had been uncovered during those audits."
The prosecutor said one worker, Mark Kovacs, came to the UK and was put into overcrowded accommodation by Janos Orsos and his people-trafficking organisation.
Orsos was jailed for five years for people trafficking in May 2014.
Mr Tehrani told the court: "He (Mr Kovacs) describes people sleeping anywhere they could - in beds, bunk-beds, on mattresses, on the table or on the floor.
"The house was overcrowded."
Mr Rafiq, of Thorncliffe Road, Staincliffe, Mr Patel, of Carr Side Crescent, Batley, and Mr Dadhiwala, of Upper Mount Street, Batley Carr, all deny a single count of conspiracy to traffic individuals within the UK.
The trial continues.
A series of high street retailers' ethical audits failed to spot one of their suppliers was employing "a slave workforce", a jury has been told.