To qualify for a bad debt deduction, the underlying debt must be bona fide. That is, you must have loaned the money or extended credit with the expectation that you would be repaid and with the intent to enforce collection if you weren’t repaid.
It’s common for owners of closely held businesses to transfer money into and out of the company. But it’s critical to make such transfers properly. If you don’t, you might hear from the IRS.