In a Chapter 7 you cannot discharge tax liability for the most recent three years before the filing of the bankruptcy on filed returns. If the liability is more than three years old and the returns for those years has been filed then it can be discharged.
There is more to consider than the 3 year element. Some tax liabilities are not dischargeable even though many more than three years have passed. One of the reasons for your confusion is that it is confusing to everyone. Even if you take the time to study and work through the entire analysis and then apply it to your specific situation, it still may be confusing. To get the best outcome, you should seek both bankruptcy advice and tax advice to deal with complex issues. The cost of getting good advice, will probably save you time, stress, and money in the long run.