Is it safe to take expired Advil (ibuprofen)? I heard that the medication becomes less effective.

Expired medications. Medications that are passed their expiration dates can be less effective, or contaminated. Some medications could even decompose into products that can be harmful. It isn't worth the risk to take expired medications, so regularly clear out your medicine cabinet and replace with fresh medications.
Safety is relative. If the OTC pain medicine has just expired, within a couple of months, it probably would be OK to use. As u pointed out yourself, expired meds start losing its potency depending upon the time lapsed. It is always a good practice to regularly clean your medicine closet for expired drugs, as they pose potential risk for unintended use and not let you replenish your stock when you would need them.